none
Open existing document in Word Add-in RRS feed

  • Question

  • Hi,

    I have created a VSTO solution for Word Addin in VS2010.

    In My addin I have created three buttons in Ribbon . And I have created two Custom Task panes as usercontrol

    1. While clicking on Button 1 I have written the code to add custom task panes to add-in

    Globals.ThisAddIn.CustomTaskPanes.Add(UCCustomtaskpane, "Taskpane1");

    If button 2 is clicked then I have written the code to show custom task pane.

    Everything is working fine.But in word if i open existing document then click on button 2  custom task pane not loading.

    Steps to reproduce :

    1.Open word application.

    2.Open existing document say document 1.doc.

    3.Click on Button 1.

    4.Open existing document say Document 2.doc .(Now one more instance of word opened).

    5.In Document 2 click on button 2(which will load custom task pane).It doesnot load task pane. But it opens the task pane in Document 1.

    If I click on button 2 in document 2 it opens Custom task pane in Document 1...

    What is the problem (Is it using same object reference). 

    Could you please suggest what are the steps we need to follow in our project.how to create instance specific add-in

    Thanks,

    Karthik.K

    Thursday, September 4, 2014 5:36 PM

Answers

  • Hi,

    According to your description, I think this behavior is by design.

    Custom task panes are associated with a document frame window, which presents a view of a document or item to the user. The task pane is visible only when the associated window is visible. Word displays each document in a different document frame window. When you create a custom task pane for Word, the custom task pane is associated only with a specific document. If the user opens a different document, the custom task pane is hidden until the earlier document is visible again. (From Custom Task Panes)

    So in your case, the custom task pane is associated only with the frame window of Document 1.doc. When you open Document 2.doc and click button2, it will display the custom task pane in Document 1.

    If you want to display a custom task pane with multiple documents, create a new instance of the custom task pane when the user creates a new document or opens an existing document. To do this, handle events that are raised when a document is created or opened, and then create the task pane in the event handlers. You can also handle document events to hide or display task panes depending on which document is visible.

    More details about managing custom task panes in multiple documents, please refer to the links below.

    Managing Custom Task Panes in Multiple Application Windows

    Managing Task Panes in Multiple Word and InfoPath Documents


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 11, 2014 7:12 AM
    Moderator

All replies

  • Hello Karthik,

    > If button 2 is clicked then I have written the code to show custom task pane.

    What code do you use for the button2? Could you please be more specific?

    > Now one more instance of word opened

    Is it a new process or just a new window? Did you have a chance to check out the list of running processes?

    Thursday, September 4, 2014 6:13 PM
  • Hello Eugene,

    1. I have created property for Custom task pane to set visible property.

    On button 2 click I have set the visible property of Task pane to true.

    Globals.ThisAddIn.UCCustomtaskpane.visible=true

    2. It opening as a new window not a new process.

    Regards,

    Karthik.K

    Friday, September 5, 2014 8:37 AM
  • please suggest how to implement
    Thursday, September 11, 2014 6:46 AM
  • Hi,

    According to your description, I think this behavior is by design.

    Custom task panes are associated with a document frame window, which presents a view of a document or item to the user. The task pane is visible only when the associated window is visible. Word displays each document in a different document frame window. When you create a custom task pane for Word, the custom task pane is associated only with a specific document. If the user opens a different document, the custom task pane is hidden until the earlier document is visible again. (From Custom Task Panes)

    So in your case, the custom task pane is associated only with the frame window of Document 1.doc. When you open Document 2.doc and click button2, it will display the custom task pane in Document 1.

    If you want to display a custom task pane with multiple documents, create a new instance of the custom task pane when the user creates a new document or opens an existing document. To do this, handle events that are raised when a document is created or opened, and then create the task pane in the event handlers. You can also handle document events to hide or display task panes depending on which document is visible.

    More details about managing custom task panes in multiple documents, please refer to the links below.

    Managing Custom Task Panes in Multiple Application Windows

    Managing Task Panes in Multiple Word and InfoPath Documents


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, September 11, 2014 7:12 AM
    Moderator