ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Slow down SendKeys macro (https://www.excelbanter.com/excel-programming/338586-slow-down-sendkeys-macro.html)

[email protected]

Slow down SendKeys macro
 
Hello,

I have a macro that sends several sendkey commands to modify some
settings within a printer's print settings dialog box. The problem is
that the macro seems to be too fast for the application at times, and
the keys are sent before the application is at the place it needs to
be. If I print the macro and key the sequence in by hand it works
perfectly. I would like to add a quarter second delay between all the
keys that are pressed in the sequence if possible. I've examined some
loop commands, but they have resulted in much more agony than help. Any
idea on how to keep the macro from moving too fast? Thanks for any
help.


RB Smissaert

Slow down SendKeys macro
 
Try this:

At the top of the normal code module put this:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Then at any place in your code you want a delay put:
Sleep 250

Experiment with the number 250 and see if you need more delay or if you can
do with less.

RBS


wrote in message
oups.com...
Hello,

I have a macro that sends several sendkey commands to modify some
settings within a printer's print settings dialog box. The problem is
that the macro seems to be too fast for the application at times, and
the keys are sent before the application is at the place it needs to
be. If I print the macro and key the sequence in by hand it works
perfectly. I would like to add a quarter second delay between all the
keys that are pressed in the sequence if possible. I've examined some
loop commands, but they have resulted in much more agony than help. Any
idea on how to keep the macro from moving too fast? Thanks for any
help.




All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com