英文:
MS Word Custom Task Pane disappears when clicking on File menu
问题
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?
英文:
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?
答案1
得分: 1
自定义任务窗格不提供任何关于此的事件。这是因为它并没有真正关闭,当它显示时,后台UI会隐藏任何UI。
您可以通过处理Office应用程序中的File菜单打开时的Backstage UI的onHide和onShow事件来检测,这样您就会在后台UI关闭和打开时得到通知。
onShow回调应该具有以下签名:
C#: void OnShow(object contextObject)
Visual Basic: Sub OnShow(contextObject As Object)
C++: HRESULT OnShow([in] Object *pContextObject)
onHide回调应该具有以下签名:
C#: void OnHide(object contextObject)
Visual Basic: Sub OnHide(contextObject As Object)
C++: HRESULT OnHide([in] Object *pContextObject)
英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论