Word COM Addin (user input form) RRS feed

  • Question

  • Hi,

    I am just beginning to dabble in Visual Basic/Visual Studio.  I've created dozens of Word Template AddIns over the years and want to learn how to create a Word COM Addin.  I have Visual Studio 2010 professional with VSTO installed.

    Through extensive trial and error over the past three days, I've managed to create a basic add-in that displays a ribbon tab with a control button.  When the control button is clicked a "windows form" is presented and the user can enter data (I've created a very basic find and replace dialog). When the user executes the operation is completed and the form is closed.

    My questions are related to the windows form. 

    1.  I noticed that after the form is closed that the Word document does not automatically have the focus.  It is there (visible) but in order to begin typing I had to physically click in the document.  I displayed the form using .ShowDialog().  I had mentioned this anomaly along with a laundry list of other basic questions in the Visual Basic group and was advised to show the form using .Show.  When I did this, the issue of focus was resolved.  However, that created a new issue.  It seems that a windows form .ShowDialog() is sort of like a VBA userform .Show and a windows form .Show behaves sort of like a VBA userform .Show vbModeless.  When I change from .ShowDialog() to just .Show() I was able to click in the document before closing the form.  The problem then was that unlike a vba modeless userform the windows form was hidden behind the document.

        a. Is a windows form the correct tool for what I am trying to do?

        b. How do I display the form so that it is persistent (holds the focus) until the user closes or executes and then automatically return the focus to the document (eliminate need to first click in the document)

        c. How do I make the form behave like a vba modeless userform (i.e., remain visible when switching between the document and the form).

        d. How do I prevent the user from resizing the displayed form.

        e. Other that using the form properties to remove the "X, minimize and maximize buttons can those buttons be disabled (there but dimmed)


     Cross posted at:


    Greg Maxey Please visit my website at:

    • Edited by Greg Maxey Monday, November 24, 2014 5:15 PM cross post
    Monday, November 24, 2014 1:10 PM

All replies