Word Macros- adding a pause while auto typing.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jackjack
    New Member
    • Jun 2007
    • 3

    Word Macros- adding a pause while auto typing.

    Hiya,

    I'm completely useless with Visual Basic but this should be pretty easy to do. This is regarding MACROS in Microsoft Word by the way...

    Basically I want to open a word document and I would like a sentance to be typed letter by letter.

    Then (here's what I am having trouble with) I would like it to pause typing for a given ammount of time EG. 15 seconds before it continues.

    Then I would like it to continue writing... How can I put a pause in there?

    All it is for is a live comedy routine I am devising whereby I talk to a computer... and it talks back letter by letter (hence the pause). It's that simple!

    Your help would be amazing.

    Thank you very much.

    Jack
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    This subject has come up before. You can try using the search box for key termns such as "Excel", "wait", "sleep", "pause", "delay" and so on.

    But this thread may provide what you need. (I believe VBA is fairly consistent between Excel and Word, and Excel questions seem to come up more frequently.)

    Comment

    • jackjack
      New Member
      • Jun 2007
      • 3

      #3
      I shall look into that. Thank you. BUT I honestly have NO clue about ANYTHING VB, this is the first time I have ever attempted it. My friend managed to program this, it types a sentace letter by letter:

      I've also been told to look into Timer and DoEvents functions. but i wouldn't know where to put them in here :S

      [CODE=vb]Sub testing()

      Dim start As Single
      Dim message As String

      message = "THIS IS THE FIRST BIT OF TEXT TO BE SPELT OUT."
      speedupper = 0.02
      speedlower = 0.005

      Characters = Len(message)

      Selection.Font. Name = "Impact"
      Selection.Font. Size = 35


      For i = 1 To Characters

      start = Timer + Rnd((speedupper - speedlower + 1) * Rnd + speedlower)

      writing = Mid(message, i, 1)

      Selection.TypeT ext writing

      Do While Timer < start
      DoEvents
      Loop

      Next i

      End Sub[/CODE]

      Comment

      • jackjack
        New Member
        • Jun 2007
        • 3

        #4
        No problem.. cracked it!

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by jackjack
          No problem.. cracked it!
          Glad to hear it. :)

          However, I'd consider rewriting the calculation of the random delay, if I were you. That calculation looks quite suspect. I believe RND always returns a value between 0 and 1, and the number you feed it (the "seed") simply starts the sequence of pseudo-random values. The upper/lower business would generally be used a bit differently.

          Anyway, have fun.

          Comment

          Working...