moltib

Hi,

The situation:
- VSTO add-in for Excel
- a workbook is edited in-place (Wordpad or Word)

Problem:
- wiring any events like Application_WorkbookActivate in the startup makes Excel hang; the shutdown or Application_WorkbookOpen events are not triggered; killing Excel and starting it again, it offers to recover the in-place edited file, meaning the OLE document was not correctly closed.
- if no events are wirred Excel stops correctly (when WordPad or Word document is closed)

Any idea

Thanks!



Re: Visual Studio Tools for Office VSTO C# Add-In Excel In-Place Activation

Cindy Meister

What you're seeing is "expected", if not really desirable, and there's not really any good way around it. See these message threads, especially the explanations by Andrew Whitechapel

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=880672&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1149601&SiteID=1






Re: Visual Studio Tools for Office VSTO C# Add-In Excel In-Place Activation

moltib

Hi Cindy,

Thank you for your help.
This means that as soon an Excel VSTO add-in is installed, any in-place activation of an Excel OLE embeded object will end up in an Excel process hanging. Also the edited OLE object is kept in memory.
If this is true than it sounds as a real problem.








Re: Visual Studio Tools for Office VSTO C# Add-In Excel In-Place Activation

Cindy Meister

I don't think it means that Excel will always crash. It didn't in my case, and did only under certain circumstances in the other case. If you can trap that the object is being opened in-place your Add-in should be able to unload itself. I'm pretty sure Excel has an Addins collections (Word does). If you test "where" the application is on startup...

Another possibility would be a "manager" - either in Excel VBA or a separate Add-in - that checks the UserControl and unloads the Add-in(s) when the circumstances are wrong.

You might also check whether the problem persists if the workbook is opened in a separate Excel window, rather than in-place. If that's OK, then you should be able to set things up in Word to force Excel objects to open in a separate window / disallow in-place editing. There's not a particular setting for that, but it can be forced.