Microsoft KB Archive/67648

SendKeys May Not Function Correctly with the Step Command

PSS ID Number: Q67648 Article last modified on 03- 1-1993

1.00 1.10 1.10a WINDOWS

Summary: If a macro is run with the Step (or Step SUBs) button in the Microsoft Word for Windows Macro Editor, some SendKeys commands may not function properly.

More Information: The following sample macro switches the HP LaserJet IIISi printer to landscape orientation by sending ALT+L and ENTER to the Printer Driver dialog box: Sub MAIN SendKeys “%l{enter}”, - 1 FilePrintSetup .Printer = “HP LaserJet IIISi on LPT1:”, .Setup End Sub If this macro is run using the Step (or Step SUBs) button in the Macro Editor, the SendKeys command will send the ALT+L and ENTER to the current window rather than the Printer Driver dialog box, then activate the Printer Driver dialog box. However, the Step button will properly step through a macro with SendKeys statements, if the SendKeys statement and the dialog that is receiving the keys are one the same line (separated by a colon). Sub MAIN SendKeys “%l{enter}”, - 1 :

FilePrintSetup .Printer = “HP LaserJet IIISi on LPT1:”, .Setup End Sub Use a SendKeys statement only when a WordBasic command does not providethe functionality or when Dynamic Data Exchange (DDE) functionality is not available with another application.

Reference(s): “Microsoft Word for Windows and OS/2 Technical Reference” pages 251-253. “Microsoft Word for Windows User’s Reference” pages 187-188.

Additional reference words: w4wprint w4wmacro