none
How to add a cusotucontrol to word document [ C# Word addin ] RRS feed

  • Question

  • I make a word addin to print vouchers. that contains a custom control called BarcodeWithZXing. the BarcodeWithZXing is  written by C#  and build to a Dll file. the addin reference to that.

    the question is :

    how to add the BarcodeWithZXing to document. I try the method "doc.shapes.addolecontrol ", but I didn't know the classType of BarcodeWithZXing.

    Is there any method to finish my idea? thanks !

    by the way, I was use the Microsoft access barcode 9.0 to do by VBA. but that work is not good after reopen the file.


    • Edited by Jeff Lyu Wednesday, September 23, 2015 9:50 AM
    • Moved by CoolDadTx Wednesday, September 23, 2015 1:30 PM Office related
    Wednesday, September 23, 2015 9:47 AM

Answers

  • >>>how to add the BarcodeWithZXing to document. I try the method "doc.shapes.addolecontrol ", but I didn't know the classType of BarcodeWithZXing.

    Is this customer control that you have created ActiveX control?

    COM objects, when created by name, are instantiated by registration information stored in the Windows Registry. Even though your control is created in .NET it uses COM Interop.
    There's no way to create it by name without first registering it on the user's machine.

    If this customer ActiveX control has been registered , you could user name of classType like this:

    "Namespace.CustomerControlName"

    otherwise you could add customer control to Toolbox, refer to these steps that right click "Toolbox" then click "Choose Items..." to direct your customer control dll.

    Also you could use code below to add Windows Form control or custom windows form control:

    Globals.ThisDocument.Controls.AddControl(new MyButton(), Globals.ThisDocument.Application.Selection.Range, 100, 200, "MyButton");

    • Marked as answer by Jeff Lyu Wednesday, September 30, 2015 3:49 AM
    Friday, September 25, 2015 1:11 AM

All replies

  • Is that not clearness? Why no one to response one word.

    Oky, let me try again.

    I want make voucher [like invoice, deliver,] by MSWORD.  the voucher is built then need create a BARCODE to each voucher. The BARCODE's generator is  ZXing.NET (from google a opensource project.) .

    The created BARCODE how to insert to the word document let me print.

    #------------------------------

    This are unrealistic thinking

    # 1 : The word document's container allow adding custom controls then doc.container.add( new mybarcdoe()); done.

    # 2 : The word document can add picturebox without the path argument.  ........

    # 3 : The word document

    Wednesday, September 23, 2015 2:11 PM
  • >>>how to add the BarcodeWithZXing to document. I try the method "doc.shapes.addolecontrol ", but I didn't know the classType of BarcodeWithZXing.

    Is this customer control that you have created ActiveX control?

    COM objects, when created by name, are instantiated by registration information stored in the Windows Registry. Even though your control is created in .NET it uses COM Interop.
    There's no way to create it by name without first registering it on the user's machine.

    If this customer ActiveX control has been registered , you could user name of classType like this:

    "Namespace.CustomerControlName"

    otherwise you could add customer control to Toolbox, refer to these steps that right click "Toolbox" then click "Choose Items..." to direct your customer control dll.

    Also you could use code below to add Windows Form control or custom windows form control:

    Globals.ThisDocument.Controls.AddControl(new MyButton(), Globals.ThisDocument.Application.Selection.Range, 100, 200, "MyButton");

    • Marked as answer by Jeff Lyu Wednesday, September 30, 2015 3:49 AM
    Friday, September 25, 2015 1:11 AM
  • David JunFeng, Thanks for you response.

    I will be do that as you say later.


    • Edited by Jeff Lyu Friday, September 25, 2015 3:45 AM
    Friday, September 25, 2015 3:44 AM