Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting VBA (Powerpoint) to pause 4

Status
Not open for further replies.

Rebam98

Computer
Mar 28, 2006
14
Hi-

I'm encountering a problem with my code. I have a code that draws Excel charts into a PowerPoint presentation. When I step through the macro (with F8), it draws them all just fine. But if I run the macro without stepping, it gets jammed up at a certain point. I think I need to put a pause in my code to give it a second to catch up to itself. Is this likely the problem? And how do I add a pause?

Thanks,

Amber
 
Replies continue below

Recommended for you

I added a message box to slow it down and that worked. That will work for now, but hitting the message box over and over again might get old. I'll keep looking for a better answer.
 
You can use a DoEvents statement to give the other apps a chance to continue. Otherwise, a timer (see VBA help) or a do..loop can give you a pause.

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Whenever I need a pause (especially useful with a SendKeys statement) I use the following little block:

Code:
Dim WAIT As Double

WAIT = Timer
While Timer < WAIT + 2
   DoEvents  'do nothing
Wend
 
Oops, forgot to mention that the number after "WAIT +" is the amount of time in seconds you want to pause. You can use a number less than 1.
 
Thank you, handleman, for elaborating my sloppy answer.

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor