Embedded Excel OLE Orphan Preventer

This add-in is designed to correct the scenario where orphaned embedded Excel workbooks are left open even after the parent application or document has closed. The problem occurs when you edit your embedded Excel instance in another Window (usually via a right-click / Ole Object / Open). If you leave Excel open, return to Word and close the document, Excel should close. But in the VSTO COM/OLE scenario it may not always close. Instead it will remain open in Excel with the embedded workbook still in an editable state. However, it is orphaned an no longer associated with its container. Any edits you perform on the rogue instance will be lost.

This add-in corrects that issue by doing the following:
  • When a workbook is opened, it looks to see if it is embedded.
  • If it is, it connects to the running instance of Word, and gets a reference to the parent document.
  • A timer in the add-in will then continually check the status of the document
  • If the parent document is still opened, nothing happens. However, if Word is existed or the parent document is closed, the child embedding is forced closed.

Last edited Oct 4, 2012 at 6:22 PM by davidcr, version 4