XL5: Excel Displays Alerts When Activated Using CreateObject

ID: Q119378

The information in this article applies to:

SYMPTOMS

When you use the CreateObject function in a Visual Basic version 3.0 procedure to create a Microsoft Excel OLE Automation object, the procedure returns an error message if Microsoft Excel is already running.

CAUSE

Alerts are still displayed when you use the CreateObject function to run Microsoft Excel as an OLE Automation server. In general, having these alerts displayed is not a problem when you use the CreateObject function with the Application object, because add-ins, files located in the XLSTART directory, and the default new workbook are not loaded.

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q108888
   TITLE     : XL: Add-Ins Don't Load When Using CreateObject

However, this behavior does cause a problem when you use the CreateObject function to create a Sheet object, and the OnSheetActivate property has been used for any sheet in any open workbook in the current session of Microsoft Excel. In this case, the macro that is assigned to run when a sheet is activated, also runs when the sheet object is created by the Visual Basic 3.0 procedure. If this macro displays a message box, or causes a dialog box to appear, the Visual Basic 3.0 procedure may return an error message, and the OLE Automation object, (the sheet in Microsoft Excel), becomes visible.

Note that you can use the DisplayAlerts property to prevent alerts from being displayed while Microsoft Excel is being used as an OLE Automation server. However, because you cannot use the DisplayAlerts property until the OLE Automation object has been created, using DisplayAlerts does not work in the case where an alert appears as the result of the CreateObject function.

WORKAROUND

To avoid receiving an alert in Microsoft Excel when you use the CreateObject function to create an OLE Automation object, use the CreateObject function with the Application object, instead of with the Sheet object.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q111311
   TITLE     : XL5: CreateObject Function Starts Invisible Instance of
               Excel

REFERENCES

For more information about OLE Automation, click the Search button in the Visual Basic Reference and type:

   OLE Automation

Additional reference words: 5.00 err msg
Keywords          : kbdta xlvbainfo 
Version           : WINDOWS:5.0,5.0c
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: April 3, 1998