I created an addin for MS Word 365 using Custom Task Pane. Through the OnVisibleChanged method I am able to determine when to open/close the addin. The problem: by clicking the File menu (top right on the ribbon), its visibility change to false and the component disappears as if you had clicked on the "X" button. Is there any way to distinguish the close done by the "X" button? Or is there a way to not close the addin when clicking on File?
Asked
Active
Viewed 27 times
1 Answers
1
The custom task pane doesn't provide any event for that. That is because it is not really closed, the backstage UI hides any UI behind when it is displayed.
You can detect when the File
menu is opened in Office applications by handling the Backstage UI
's onHide
and onShow
events, so that you will be aware when the backstage UI is closed and opened respectively.
The onShow
callback should have the following signature:
VBA: Sub OnShow(contextObject As Object)
C#: void OnShow(object contextObject)
Visual Basic: Sub OnShow(contextObject As Object)
C++: HRESULT OnShow([in] Object *pContextObject)
The onHide
callback should have the following signature:
VBA: Sub OnHide(contextObject As Object)
C#: void OnHide(object contextObject)
Visual Basic: Sub OnHide(contextObject As Object)
C++: HRESULT OnHide([in] Object *pContextObject)

Eugene Astafiev
- 47,483
- 3
- 24
- 45