XL98: Warning Appears When You Use GetObject to Open Workbook

Last reviewed: March 18, 1998
Article ID: Q182719
The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

If 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 workbook you are opening contains macros. Some macros may contain
   harmful viruses. If you are sure this workbook is from a trusted
   source, click Yes. If you are not sure and want to prevent any macros
   from running, click No.

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:

  • You are using Automation to control Microsoft Excel 98 Macintosh Edition from another program, such as Microsoft Word 98 or Microsoft PowerPoint 98.

        -and-
    
  • The line of code you are using to open the workbook is similar to the following:

          Set xlWkbk = GetObject("Macintosh HD:Test")
    

        -and-
    
  • You select the Macro Virus Protection check box on the General tab in the Preferences dialog box (click Preferences on the Tools menu).

WORKAROUND

To prevent this problem from occurring, disable Macro Virus Protection in Microsoft Excel 98 Macintosh Edition. Note that 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 98 Macintosh Edition, follow these steps:

  1. On the Tools menu, click Preferences.

  2. Select the General tab.

  3. Click to clear the Macro Virus Protection check box.

  4. Click OK.

Note that you cannot programmatically disable the Macro Virus Protection feature. Also, you cannot programmatically detect whether the feature is available or unavailable; you must do this manually.

MORE INFORMATION

In Microsoft Excel 98 Macintosh Edition, 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.

If you use the GetObject method of Automation to open a Microsoft Excel workbook that contains macros, and if Macro Virus Protection is available, you receive a warning message when you open the workbook.

Example:

If you make Macro Virus Protection available in Microsoft Excel 98 Macintosh Edition, and the workbook "Test" contains any macros, you receive the error message when you run the following sample Sub procedure:

   Sub TestOLEAutomation()

      ' Dimension variables.
      Dim xlWkbk As Object

      ' The error message appears when this line is executed.
      Set xlWkbk = GetObject("Macintosh HD:Test")

      ' Display the program and document windows, and then close the
      ' workbook.
      xlWkbk.Parent.Visible = True
      xlWkbk.Parent.Windows(xlWkbk.Name).Visible = True
      xlWkbk.Close SaveChanges:=True

      Set xlWkbk = Nothing

   End Sub


Additional query words: XL98
Keywords : kberrmsg kbprg kbdta kbdtacode
Version : MACINTOSH:98
Platform : MACINTOSH
Issue type : kbprb


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