none
Code to manipulate ActiveX contained in a template RRS feed

Answers

  • Hi IOcc

    Show me the code you're using in the template and tell me whether you've put it in ThisDocument or a regular module.

    Most likely, you've put it in ThisDocument and are using ThisDocument to access the control. If you think about it, the problem is obvious: the controls you want to work with aren't in "this document" (the template), but in another document. That means you have to work with the controls differently.

    ActiveX controls are also graphical objects in Word. Their programming interface can be accessed via the InlineShapes (or Shapes) collection. For example:

        Dim lblTest As Label
        Set lblTest = ActiveDocument.InlineShapes(1).OLEFormat.Object
        lblTest.Caption = "Hello"
        lblTest.ForeColor = &H80&

    If you want to identify the InlineShape lable control more specifically, you can select it and insert a bookmark around it. Then you get the InlineShape of the Bookmark's Range. More like this:

    ActiveDocument.Bookmarks("MyLabel").Range.InlineShapes(1).OLEFormat.Object


    Cindy Meister, VSTO/Word MVP

    Friday, April 27, 2012 8:59 AM
    Moderator