Insert activex user control using c# in word issue RRS feed

  • Question

  • I created on activex user control using c#. Then I built it to dll file and regasm this dll to system

    This user control just simple example has one button and source code this file like it:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;

    namespace ActiveXTest
        public partial class DemoTestUserControl : UserControl
            private string myParam = "Empty";

            public DemoTestUserControl()

            /// <summary>
            /// Parameter visible from JS
            /// </summary>
            public string MyParam
                    return myParam;
                    myParam = value;

            private void button1_Click(object sender, EventArgs e)

    I created one marco function to insert this control to office word like as:

    Public Sub DPWPTextReferencePaste()

       Const TEXT_REFERENCE_CLASS As String = "DemoTestUserControl"

       Dim ishInlineShape            As InlineShape

       ' Create the text reference object
       Set ishInlineShape = ActiveDocument. _
                            InlineShapes. _
                            AddOLEObject( _
                               ClassType:=TEXT_REFERENCE_CLASS, _
                               DisplayAsIcon:=False, _

    When I call this function it already insert the control to word
    But after saving and opening it again the control doesn't show it in correctly. I can't see this button and click it. Just see red cross image in word

    Somebody can help me this issue. How can I save it and open it again like insert button time

    Saturday, December 10, 2016 9:49 AM

All replies

  • Hi Tuan Kieu,

    From the description of thread it's looks like after creating the dll file.

    you add the reference in VBE.

    so that you are able to use the functionality of that class.

    then when you close and reopen the file at that time the reference get broke and because of that you are not able to view the button.

    do you get any error? if so then let us know about that.

    also try to link to file option true and check whether it work or not.




    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, December 12, 2016 2:41 AM