Can anyone tell me how to accomplish this, please?

Excel has a WAIT function, but Word doesn't seem to recognize it.

Thanks

Pete

Re: Making a macro pause for a few seconds by Jonathan

Jonathan
Fri Mar 11 06:48:39 CST 2005


"Peter Rooney" <PeterRooney@discussions.microsoft.com> wrote in message
news:9409EAA6-FE3F-4769-A160-93E859BC911D@microsoft.com...
> Can anyone tell me how to accomplish this, please?
>
> Excel has a WAIT function, but Word doesn't seem to recognize it.
>


Put this statement before the first Sub or Function in any module

Public Declare Sub Sleep Lib "kernel32" _
Alias "Sleep" (ByVal dwMilliseconds As Long)

Then you can call it anywhere in your code like this

Sleep 100 'inserts a 100ms pause


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org


Re: Making a macro pause for a few seconds by Helmut

Helmut
Fri Mar 11 06:52:50 CST 2005

Hi Peter,

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds
As Long)

Or if you prefer something simple, not to say primitive:

Public Sub Wait(ByVal aNum As Integer)

Dim aTim As Single
aTim = Timer
While Timer < aTim + aNum
DoEvents
Wend
End Sub

I put a lot of effort in this,
if you need to wait for
10 days, 4 hours, 2 minutes, 4 seconds ;-)

ask again

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/



Re: Making a macro pause for a few seconds by Greg

Greg
Fri Mar 11 06:53:20 CST 2005

Pete,

Not sure if this helps, but how about something like:

Sub Doze(ByVal lngPeriod As Long)
DoEvents
Sleep lngPeriod
' Call it in desired location to sleep for 10 seconds like this:
' Doze 10000
'Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long) must
'appear in the module level
End Sub


Re: Making a macro pause for a few seconds by PeterRooney

PeterRooney
Fri Mar 11 08:05:08 CST 2005

Thank you, Jonathan - this works fine!
Now all I need is a pointer to a good on-line downloadable Word VBA
reference -
any ideas?

Have a good weekend

Pete



"Jonathan West" wrote:

>
> "Peter Rooney" <PeterRooney@discussions.microsoft.com> wrote in message
> news:9409EAA6-FE3F-4769-A160-93E859BC911D@microsoft.com...
> > Can anyone tell me how to accomplish this, please?
> >
> > Excel has a WAIT function, but Word doesn't seem to recognize it.
> >
>
>
> Put this statement before the first Sub or Function in any module
>
> Public Declare Sub Sleep Lib "kernel32" _
> Alias "Sleep" (ByVal dwMilliseconds As Long)
>
> Then you can call it anywhere in your code like this
>
> Sleep 100 'inserts a 100ms pause
>
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>
>

Re: Making a macro pause for a few seconds by PeterRooney

PeterRooney
Fri Mar 11 08:05:09 CST 2005

Thanks, Helmut - I went for the complicated option!

Have a good weekend!

Pete



"Helmut Weber" wrote:

> Hi Peter,
>
> Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds
> As Long)
>
> Or if you prefer something simple, not to say primitive:
>
> Public Sub Wait(ByVal aNum As Integer)
>
> Dim aTim As Single
> aTim = Timer
> While Timer < aTim + aNum
> DoEvents
> Wend
> End Sub
>
> I put a lot of effort in this,
> if you need to wait for
> 10 days, 4 hours, 2 minutes, 4 seconds ;-)
>
> ask again
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP
> "red.sys" & chr(64) & "t-online.de"
> Word XP, Win 98
> http://word.mvps.org/
>
>
>

Re: Making a macro pause for a few seconds by PeterRooney

PeterRooney
Fri Mar 11 08:15:04 CST 2005

Greg,

Thanks for this - it works fine, although I'm not sure I know why..! :))
I think I need a nice downloadable Word VBA reference to fully understand
ByVALs & stuff - any Ideas where I might find one?

Regards & have a good weekend

Pete



"Greg" wrote:

> Pete,
>
> Not sure if this helps, but how about something like:
>
> Sub Doze(ByVal lngPeriod As Long)
> DoEvents
> Sleep lngPeriod
> ' Call it in desired location to sleep for 10 seconds like this:
> ' Doze 10000
> 'Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
> Long) must
> 'appear in the module level
> End Sub
>
>

Re: Making a macro pause for a few seconds by Jay

Jay
Fri Mar 11 08:39:36 CST 2005

Hi Pete,

The entire VBA help system is on the MSDN web site, if you don't want to use
the one that's already installed on your computer. Start at
http://msdn.microsoft.com/library/en-us/off2000/html/wohowFrequentlyAsked.asp.
Use the left-hand navigation pane to find the rest of the topics.

Within the VBA editor, put the cursor on any keyword (such as ByVal) and
press F1 to open directly to the help topic about that word.

The Macros section of the FAQs at http://word.mvps.org is a good but
disorganized set of reference material. Try using the Search facility to
find topics that use the things you're interested in.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Peter Rooney wrote:
> Greg,
>
> Thanks for this - it works fine, although I'm not sure I know why..!
> :)) I think I need a nice downloadable Word VBA reference to fully
> understand ByVALs & stuff - any Ideas where I might find one?
>
> Regards & have a good weekend
>
> Pete
>
>
>
> "Greg" wrote:
>
>> Pete,
>>
>> Not sure if this helps, but how about something like:
>>
>> Sub Doze(ByVal lngPeriod As Long)
>> DoEvents
>> Sleep lngPeriod
>> ' Call it in desired location to sleep for 10 seconds like this:
>> ' Doze 10000
>> 'Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
>> Long) must
>> 'appear in the module level
>> End Sub



Re: Making a macro pause for a few seconds by Greg

Greg
Fri Mar 11 08:43:59 CST 2005

Pete,

LOL, You are not the only one stumbling along in darkness. I have
learned the little that I know about VBA by following this group and
asking lots of question. As time goes by you start to answer a few.
Hopefully one day I will understand the answers :-). The Help in VBA
and the F1 key provides answers to lots of questions too. Good luck.


Re: Making a macro pause for a few seconds by PeterRooney

PeterRooney
Fri Mar 11 08:51:02 CST 2005

Cheers, Jay!

I may be old-fashioned, but I like a nice reference manual I can look at on
my desk, sometimes!

Thanks for your help - have a good weekend!

Pete



"Jay Freedman" wrote:

> Hi Pete,
>
> The entire VBA help system is on the MSDN web site, if you don't want to use
> the one that's already installed on your computer. Start at
> http://msdn.microsoft.com/library/en-us/off2000/html/wohowFrequentlyAsked.asp.
> Use the left-hand navigation pane to find the rest of the topics.
>
> Within the VBA editor, put the cursor on any keyword (such as ByVal) and
> press F1 to open directly to the help topic about that word.
>
> The Macros section of the FAQs at http://word.mvps.org is a good but
> disorganized set of reference material. Try using the Search facility to
> find topics that use the things you're interested in.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
>
> Peter Rooney wrote:
> > Greg,
> >
> > Thanks for this - it works fine, although I'm not sure I know why..!
> > :)) I think I need a nice downloadable Word VBA reference to fully
> > understand ByVALs & stuff - any Ideas where I might find one?
> >
> > Regards & have a good weekend
> >
> > Pete
> >
> >
> >
> > "Greg" wrote:
> >
> >> Pete,
> >>
> >> Not sure if this helps, but how about something like:
> >>
> >> Sub Doze(ByVal lngPeriod As Long)
> >> DoEvents
> >> Sleep lngPeriod
> >> ' Call it in desired location to sleep for 10 seconds like this:
> >> ' Doze 10000
> >> 'Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
> >> Long) must
> >> 'appear in the module level
> >> End Sub
>
>
>

Re: Making a macro pause for a few seconds by PeterRooney

PeterRooney
Fri Mar 11 08:53:05 CST 2005

Greg,
I actually have helped a few people on Excel VBA and a couple on Project VBA
too- it's always a race to be the first and get the green tick, but it's good
when you do!

Thanks for your help

Pete



"Greg" wrote:

> Pete,
>
> LOL, You are not the only one stumbling along in darkness. I have
> learned the little that I know about VBA by following this group and
> asking lots of question. As time goes by you start to answer a few.
> Hopefully one day I will understand the answers :-). The Help in VBA
> and the F1 key provides answers to lots of questions too. Good luck.
>
>