Microsoft KB Archive/76309

{|
 * width="100%"|

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

 * }

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 &quot;Steps to Reproduce Problem&quot; section.

Steps to Reproduce Problem
 Start Q+E by choosing Activate Q+E from the Data menu in Excel. Then minimize Q+E.  Enter the following into a macro sheet:      A1:  =SEND.KEYS(&quot;^{ESC}Q%S&quot;,TRUE) A2: =SEND.KEYS(&quot;%S&quot;,TRUE) A3: =SEND.KEYS(&quot;{LEFT}{RIGHT 5}~&quot;,TRUE) A4: =RETURN  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(&quot;^{ESC}Q%S&quot;,TRUE) A2: =SEND.KEYS(&quot;%S {LEFT}{RIGHT 5}~&quot;,TRUE) A3: =RETURN Reference(s) :

&quot;Microsoft Excel Function Reference,&quot; version 3.0, page 166

Additional query words:

Keywords :

Version :

Platform :

Issue type :

Technology :