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

Last reviewed: November 2, 1994
Article ID: Q76309

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.