ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Leftover Workbooks Named "Object" When Opening Excel In IE (https://www.excelbanter.com/excel-programming/364307-leftover-workbooks-named-object-when-opening-excel-ie.html)

Drew Lettington

Leftover Workbooks Named "Object" When Opening Excel In IE
 
I'm experiencing a problem when I open a workbook from Internet Explorer (for
example, clicking on a hyperlink to a .xls file) and my system is configured
to open Excel in a brower window. If Excel is opened before I click the link
in IE then when I close the browser window that was displaying the workbook,
an empty workbook named "Object" is left open in Excel. Each time an Excel
link
is opened in IE and then the browser window is closed, additional workbooks
named "Object2", "Object3", ... are left open.

I tracked the issue to a COM add-in (disabling the add-in caused the problem
to go away) and in particular creating an Excel event handler in the add-in.
Note: it doesn't appear to matter which event handler is created and the
handler doesn't even need to contain any code to make the issue appear. Just
defining an event handler in VBA doesn't appear to cause the problem.

Has anyone seen this problem or know anything about how to resolve it?

It's easy to produce the problem by creating a new Office COM add-in using
the Visual Studio .NET 2003 project wizard, then add an event handler:

// I added the reference to Office XP Primary Interop Assembly (PIA) for Excel
using Excel = Microsoft.Office.Interop.Excel;

// This code was generated by the wizard
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
applicationObject = application;
addInInstance = addInInst;

// I added this code
Excel.Application excelApp = (Excel.Application)applicationObject;
excelApp.WorkbookOpen += new
Microsoft.Office.Interop.Excel.AppEvents_WorkbookO penEventHandler(excelApp_WorkbookOpen);
}

// I added the empty event handler
private void excelApp_WorkbookOpen(Microsoft.Office.Interop.Exc el.Workbook Wb)
{
}

If the event handler is in the code then the workbooks are left open. If I
comment out adding the handler to the WorkbookOpen event then they are
closed. I also tried other events and they all caused the issue.



All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com