Answered Word AddIn not starting after opening a document

  • Wednesday, March 07, 2012 9:37 AM
     
     

    Hi all !

    I've created a Word addin and it's working as I expect when I open Word directly.

    The problem show up when I open a document : my addin is not starting. I can start it from the COM AddIn menu without problem after that, but it is really boring to do that everytime...

    Thank you in advance for your answers !

    Phil



    • Edited by Phil Lep Wednesday, March 07, 2012 10:15 AM
    • Edited by Phil Lep Wednesday, March 07, 2012 12:26 PM
    •  

All Replies

  • Wednesday, March 07, 2012 10:33 AM
     
     
    just to be sure: when you open word from shrotcut or any other such means - your add-in is up and running, but when you open word by clicking document - it is not - am i correct?
  • Wednesday, March 07, 2012 12:20 PM
     
     

    To be more precise, if I open Word and no other word window (that was started from clicking on a document) is opened, then my AddIn starts.

    If a Word window that was opened from clicking on a document is openend and that I start a new one, my addin won't start...

    After that if I close all Word windows and start Word again from shortcut, my addin won't start until I start it from the COM AddIn dialog box again.

  • Wednesday, March 07, 2012 12:26 PM
     
     
    It seems like it gets disabled after some exception. Can you show us your Startup event of addin?
  • Wednesday, March 07, 2012 12:42 PM
     
      Has Code
    TextPicker textPicker1;
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
            //Create and show the custom pane
            textPicker1 = new TextPicker();
            ctpText = this.CustomTaskPanes.Add(textPicker1, "Insertion juridique", this.Application.ActiveWindow);
            ctpText.Visible = true;
    }

    I really don't see what would cause an exception to raise... my textPicker has never caused an error when I've debuged the AddIn

  • Wednesday, March 07, 2012 1:11 PM
     
     Answered

    Add try/catch around this code and log or show message box if error occurs. deploy and try new code.

    • Marked As Answer by Phil Lep Wednesday, March 07, 2012 3:57 PM
    •  
  • Wednesday, March 07, 2012 1:34 PM
     
     

    Thank you for your help: you were right and I found the bug!

    I don't know how to solve it yet: I want my cutom task pane to show when the AddIn loads, so I used this.Application.ActiveWindow. But it seems that when I start Word by clicking on a document the AddIn loads before the document opens... so there is no ActiveWindow and my AddIn crash.

    Is there an event that raise when a document loads?

  • Wednesday, March 07, 2012 1:44 PM
     
     Answered
    maybe try DocumentOpen or WindowActivate
    • Marked As Answer by Phil Lep Wednesday, March 07, 2012 3:56 PM
    •  
  • Wednesday, March 07, 2012 3:55 PM
     
     

    I solved my problem by using the Application.WindowActivate event.

    With the DocumentOpen event I had the same problem...

    Thank you very much for your help!

    Phil