Question

I have created a VSTO for MS Excel and MS Word as well. I am trying to embed OLE Object of Excel in my word document. It works for me for New Document. Now I saved this document somewhere on my hard drive (for eg C:\ drive). Now I am trying to open that word document from File -> Open . Now when I double click on table that is Excel OLE object , it shows me Message like this... enter image description here I think there is no issue in my VSTO. I have disabled both my VSTO and follow the same procedure. But failed again. Has anyone tried doing this before successfully. Please assist me with sample code.

Was it helpful?

Solution

Surround all your Application_Workbook code with try-catch-finally and release the workbook object. eg.

void Application_WorkbookOpen(Excel.Workbook Wb) { 
    try {
        // Do Stuff
    } catch (Exception) {
        // Probably Eat it
    } finally {
        Marshal.ReleaseComObject(Wb);
    }
 }

Here is a reference ...

https://theofficecontext.com/2012/10/09/vsto-and-comole/

OTHER TIPS

Its common problem you will see when you embed excel in word and is caused by addins. One solution to resolve this is in your addins (both word and excel) unhook all application and document events, like document open. Also disable any third party addin installed and check if that solves problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top