Send.Keys Macro to Size Window Doesn't Work in Excel

ID: Q76309

2.10 2.10c 2.10d 3.00 WINDOWS kbother

SUMMARY

The Excel macro shown below uses the SEND.KEYS command to activate another application (Q+E in this example) and then attempts to resize the application window. Running this macro may hang your machine.

MORE INFORMATION

The body of the following macro contains three Send.Keys commands. The first statement (A1) activates Q+E. The second statement (A2) chooses Size from the Control menu and the Sizing Arrow is displayed on the screen. The third Send.Keys (A3) should then resize the window, but may instead lock up your machine, causing you to have to reboot.

Microsoft is researching this problem and will post new information here as it becomes available.

NOTE: A workaround follows the "Steps to Reproduce Problem" section.

Steps to Reproduce Problem

1. Start Q+E by choosing Activate Q+E from the Data menu in Excel. Then

   minimize Q+E.

2. Enter the following into a macro sheet:

      A1:  =SEND.KEYS("^{ESC}Q%S",TRUE)
      A2:  =SEND.KEYS("%( )S",TRUE)
      A3:  =SEND.KEYS("{LEFT}{RIGHT 5}~",TRUE)
      A4:  =RETURN()

3. Run the macro by selecting cell A1 and choosing Run from the Macro
   menu.

Q+E has been brought into a window and the sizing arrow appears in the middle of the window, but no resizing is done. Your machine may be locked up. The last keystrokes do not get sent and are never executed.

This macro works correctly in Excel for OS/2. This macro will also work if you attempt to use it to resize an Excel worksheet in the same instance of Excel.

Workaround

Combining the second and third statements into one causes the macro to run properly because all the keystrokes are sent to Q+E at one time:

   A1:  =SEND.KEYS("^{ESC}Q%S",TRUE)
   A2:  =SEND.KEYS("%( )S {LEFT}{RIGHT 5}~",TRUE)
   A3:  =RETURN()

Reference(s) :

"Microsoft Excel Function Reference," version 3.0, page 166

KBCategory: kbother KBSubcategory:

Additional reference words: noupd

Last Reviewed: May 1, 1998