locked
Opening New Document From Application AddIn Ribbon RRS feed

  • Question

  • I am opening document level addins from an application level addin, but I am having an issue. When I open it is opening a whole new collection of the objects.

    I open word sitting on Document1 > Blank Template and Go to my Ribbon > Select the Dropdown Item Which Runs this Code

     public void SelectedItem(Office.IRibbonControl control, string selectedId, int selectedIndex)
        {
          object obj = ReturnDocument(selectedId);
          try
          {
            Microsoft.Office.Interop.Word.Application app = Globals.ThisAddIn.Application;
            if (obj is string)
            {
              app.Documents.Open(obj);
            }
          }
    
          catch (Exception ex)
          {
            new HandleException(ex);
            return;
          }
    
        }
    

     Will Open all the Document But When I Go to Close I need to Tons of Windows... Make me think instead of opening a new Doucment it is Opening a Whole new Document Collection...

     

     

    Monday, August 22, 2011 5:02 PM

Answers

  • No quite sure what was going on I did a check for document before opening and set the open document to active it is working correctly now!
    Wednesday, August 24, 2011 3:09 AM

All replies

  • Have you checked what, exactly, obj contains after ReturnDocument runs?

    What, exactly, do you mean by " Will Open all the Document ". Are you saying all the documents listed in the dropdown are opened, rather than just the one?


    Cindy Meister, VSTO/Word MVP
    Monday, August 22, 2011 6:29 PM
  • Should be a single string of the file/path to open... I will verify it is not an array of strings that is getting cancatenated.

     

    It is opening the entire collection of documents over and over again. Instead of opening like 4 I have like 10 open.

    Monday, August 22, 2011 7:01 PM
  • No quite sure what was going on I did a check for document before opening and set the open document to active it is working correctly now!
    Wednesday, August 24, 2011 3:09 AM