Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Wait or Pause Command?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Montana DOJ Help Desk - 06 Nov 2004 06:19 GMT
Word 2000

I am thinking about writing a macro that will display a 10 second count down
in a user form.  In order to do that, I would have to update the form once a
second.  I took a quick stab at making this work, but I ran into two
problems.  1) I was trying to use the Update method with my user form, and
that was causing a problem, and 2) I could not find the command in the VBA
Help to make my code wait for 1 second between each update.  What I tried
initially was similar to the following:

Dim MyDialog as Dialog

Set MyDialog = ufCountDown
For Seconds = 10 to 1 Step - 1
   lblCountDown.Caption = "Seconds remaining: " & Seconds
   MyDialog.Update
   < Command to wait 1 second>
Next

Can someone help me get this working?

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
Helmut Weber - 06 Nov 2004 11:56 GMT
Hi Tom,
just one possible way, using the caption, though.
---
Public Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Sub Makro1()
UserForm1.Show
End Sub
---
Private Sub UserForm_Activate()
Dim i As Integer
Me.Repaint
For i = 10 To 1 Step -1
  Me.Caption = Str(i)
  Sleep 1000
Next
End Sub
You may want to disable some or all controls on the form
in addition beforehand. Otherwise, if the user has clicked
on some commandbutton during the countdown,
the command would be executed after waiting.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Microsoft - 07 Nov 2004 05:18 GMT
Helmut,

Thanks for the reply.  I'll give your suggestion a try.  And good point
on disabling the other form controls too--I had not thought about that,
but it makes perfect sense.

After getting home last night, I was racking my brain over this question
and I came up with the name of the Timer function.  I looked that up in
the VBA Help, and it looks like that is the command that I was looking
for.  Also, when I looked up the Timer function, one of the related
commands that came up was the OnTime method, which might also be of some
use in solving problems like this one.

--Tom

> Hi Tom,
> just one possible way, using the caption, though.
[quoted text clipped - 23 lines]
> Word XP, Win 98
> http://word.mvps.org/

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.