XL98: Warning Appears When You Use GetObject to Open Workbook

ID: Q182719

The information in this article applies to:

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:

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

Last Reviewed: March 19, 1998