Creating and managing custom task panes for multiple documents in a VSTO Word addin

后端 未结 3 371
温柔的废话
温柔的废话 2020-12-08 23:11

I\'m developing a Word 2007-2010 addin using VSTO in Visual Studio 2008. In my addin, I need a custom task pane for each open word document. Basically, I need to create a ta

3条回答
  •  半阙折子戏
    2020-12-08 23:31

    Some things to try::

    1. Maybe you can check "Word.Application.Documents.Count" in the DocumentNew- and DocumentOpen-Event to track the actual open document.

    2. To find out if a document is already open (maybe relevant for re-open active document), you can use a dictionary of open documents. The key can the unique document name.

    3. Instead of your IsWindowAlive() method you can maybe catch the Disposed-Event as follows

    _vstoDocument.Disposed += _vstoDocument_Disposed;
    
            void _vstoDocument_Disposed(object sender, EventArgs e)
            {
                //Remove from dictionary of open documents 
            }
    

提交回复
热议问题