Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

A Visual Basic procedure that opens a workbook may halt in Excel


View products that this article applies to.

This article was previously published under Q212074

↑ Back to the top


Symptoms

In Microsoft Excel, when you run a Visual Basic for Applications Sub procedure that opens a workbook, the procedure may halt before all the code in the Sub procedure is executed.

NOTE: When the Sub procedure halts, Microsoft Excel is in "design mode." All the code in the macro that occurs before the code that opens the workbook is executed.

↑ Back to the top


Cause

This behavior occurs when the following conditions are true:
  • You assign a shortcut key to the macro.

    -and-
  • You press the shortcut key to run the macro.

    -and-
  • The SHIFT key is part of the shortcut key (for example, CTRL+SHIFT+A).

    -and-
  • The macro code opens a workbook by using the Open method (for example, Workbooks.Open).

↑ Back to the top


Resolution

To resolve this problem, remove SHIFT from the macro shortcut key combination when the code includes Workbooks.Open. To change the shortcut key for a macro, follow these steps:
  1. Start Microsoft Excel, and then open the workbook that contains the macro.
  2. Point to Macro on the Tools menu, and then click Macros.
  3. Click the macro name you want, and then click Options.
  4. In the Shortcut key box, type a letter without holding down SHIFT.
  5. Click OK, and then click Cancel.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


More information

To assign a shortcut key to a macro, follow these steps:
  1. On the Tools menu, point to Macro, and then click Macros.
  2. In the Macro name box, enter the name of the macro you want to assign to a shortcut key, and then click Options.
  3. To run the macro by pressing a shortcut key, type a letter in the Shortcut key box.

    You can use CTRL+letter or CTRL+SHIFT+letter, where letter is any letter key on the keyboard. The shortcut key overrides any default Microsoft Excel shortcut key assignments while the workbook that contains the macro is open.
  4. Click OK, and then click Cancel.

↑ Back to the top


Keywords: KB212074, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 212074
Revision : 8
Created on : 1/24/2007
Published on : 1/24/2007
Exists online : False
Views : 309