The information in this article applies to:
SYMPTOMSIf you run a Microsoft Visual Basic for Applications macro that uses the GetObject method to open a Microsoft Excel workbook, you may receive the following error message: The macro pauses until you click Yes, No, or Cancel. Note that if the macro is designed to run unattended, this behavior may cause a problem. CAUSE
You may receive this error message when the following conditions are true:
-and- -and- WORKAROUNDTo prevent this problem from occurring, use either of the following methods. Method One: Turn Off Macro Virus ProtectionIf you clear the Macro Virus Protection check box in Microsoft Excel 97, the problem described in this article does not occur. However, making Macro Virus Protection unavailable makes it possible (although unlikely) for a macro virus to infect your Microsoft Excel workbooks.To make Macro Virus Protection unavailable in Microsoft Excel 97, follow these steps:
Method Two: Use SendKeys to Bypass the Error MessageIf you know that the Macro Virus Protection feature is available when you open a Microsoft Excel workbook, you can use the SendKeys method to bypass the error message dialog box. Although this method allows you to use the Macro Virus Protection feature, it may cause an errant "y" character to appear somewhere in one of your programs or open files, so use this method with caution.To use this method, insert the following line of code into your Visual Basic for Applications macro
immediately BEFORE the following line of code that opens the Microsoft
Excel workbook. The following sample line of code opens the Text.xls
workbook in the My Documents folder:
The "y" character that is sent by the SendKeys statement is used to trigger
the "Yes" button in the error message dialog box so the macro continues
running without pausing. If the dialog box does not appear, the "y" may
appear in a program or be inserted in an open file. It is not possible to
predict where the "y" will be inserted.
MORE INFORMATION
In Microsoft Excel 97, the Macro Virus Protection feature is designed to
prevent macro viruses, such as the ExcelMacro/Laroux virus, from running.
If you select the Macro Virus Protection check box, you are prompted to
enable or disable macros whenever you open a workbook that contains macros.
Additional query words: XL97
Keywords : kbprg kbdta kbdtacode KbVBA |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |