For some reason, the problem only occurs when I hook the
WorkbookBeforeClose event. Nonetheless, I solved the problem with the
following:
1) Release your reference to
ExcelDna.Integration.ExcelDnaUtil.Application in the AutoClose event:
public void AutoClose()
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(YOUR_Application_OBJECT);
}
2) Release the com object provided as a parameter to each event:
private static void Event_WorkbookBeforeClose(Workbook Wb, ref bool
Cancel)
{
// ... code ...
System.Runtime.InteropServices.Marshal.ReleaseComObject(Wb);
}
private static void Event_WorkbookActivate(object obj)
{
// ... code ...
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
}
I hope this helps anyone else that encounters this problem. Keep up
the good work Govert.
> It looks like this problem is not unique to Excel-DNA:
http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/04/11/excel-ol...http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/74aaea5b-a1...
>
> The first link also suggests a complicated-looking workaround.
>
> Let us know what you find.
>
> -Govert
>
> On Mar 30, 7:10 am, Mad1523 <
mad1...@gmail.com> wrote:
>
>
>
> > Hey guys,
>
> > I found an issue when you try to edit an embedded Excel 2007
> > spreadsheet in Word while an exceldna addin is loaded. When I have an
> > excel addin (C# dll) that hooks the event WorkbookBeforeClose, and I
> > try to right click on embeded spreadsheet in Word 2007 and click Edit,
> > I get a combination of these errors:
>
> > "The program used to create this object is Excel. That program is not
> > installed on your computer. To edit this object, you must install a
> > program that can open the object."
>
> > or
>
> > "Microsoft Office Word can't start the application required to open
> > this object. An error occurred and this feature is no longer
> > functioning properly. Would you like to repair this feature now?"
>
> > When I comment out the hook of the WorkbookBeforeClose event in my
> > addin and perform the same procedure, I'm able to edit the embedded
> > spreadsheets in Word. This happens even if there is no code in my
> > event handler function and even when the entire add-in dll only
> > implements a blank AutoOpen, AutoClose, and the handler function.
>
> > Has anyone else encountered this problem?- Hide quoted text -
>
> - Show quoted text -