XL97: ALT Key Stuck On After Running Macro with Copy Method

Last reviewed: March 13, 1998
Article ID: Q178026
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

When you run a Microsoft Visual Basic for Applications macro or procedure that copies a worksheet, Microsoft Excel may behave as if the ALT key is stuck after the macro or procedure is finished. The behavior is evident when you press a key that normally displays a menu when pressed in combination with the ALT key (for example, ALT+F displays the File menu). This behavior will continue until you type something into a cell of a worksheet.

CAUSE

The behavior may occur under the following conditions:

  • You open Microsoft Excel 97.

        -and-
    
  • You immediately run a macro or procedure that uses the Copy method to copy a worksheet to the same workbook where the source worksheet exists.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

To work around this behavior, you can use the WindowState property in Visual Basic for Applications to minimize and maximize the Microsoft Excel application window. Follow these steps to create a sample macro that demonstrates this alternative:

  1. Open the file in Microsoft Excel 97 for Windows.

  2. Press ALT+F11 to open the Visual Basic Editor.

  3. On the Insert menu, click Module.

  4. Type the following macro code in the new module:

          ' This macro makes copies of a copied sheet in such a way that the
          ' ALT key does not stick.
    

          Sub Test()
    
             ' Makes a copy of the active sheet and places the copy after the
             ' active sheet.
             ActiveSheet.Copy After:=ActiveSheet
    
             ' Minimizes Microsoft Excel.
             Application.WindowState = xlMinimized
    
             ' Maximizes Microsoft Excel.
             Application.WindowState = xlMaximized
    
          End Sub
    
    

  5. Press ALT+F11 to switch to Microsoft Excel.

  6. On the Tools menu, point to Macro, and then click Macros. In the Macro Name list, click Test. Click Run.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Excel 97 for Windows. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

REFERENCES

For more information about the Copy method, click the Office Assistant while in the Visual Basic Editor, type "Copy method," click Search, and then click to view "Copy Method (Excel 97)."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176476
   TITLE     : OFF: Office Assistant Not Answering Visual Basic Questions


Additional query words: XL97 8.0
Keywords : kbcode kbprg xl97vbmigrate
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbworkaround


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: March 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.