none
Identifying a content control in a Word 2013 document and accessing the current "text" value of the control. RRS feed

  • Question

  • I'm new to VBA and need to better understand the syntax for identifying, accessing control "value" and setting the value from a user form.

    My task is this, I have a word document containing the new Content Controls. I need to be able to access each individual control to initialize a UserForm control. I then need to update the "values of the controls on exiting the UserForm. Can someone proved some simple sample code showing this functionality? I have surmised that the "range" attribute holds the value of the control but I need the textual or logical value of the control.

    Thanks.

    Friday, April 3, 2015 4:16 PM

Answers

  • Hi Gunteacher,

    My task is this, I have a word document containing the new Content Controls. I need to be able to access each individual control to initialize a UserForm control. I then need to update the "values of the controls on exiting the UserForm.

    What's content control you are using? Based on my understanding, we can indentify the content control by its tag and get the value of content control and initialize the control on the userform in the initialize event of userform. For example, code below is that get the text of rich text content control:

    ActiveDocument.ContentControls(1).Range.Text

    And here are some helpful links about content control for your reference:
    ContentControl Object (Word)

    Working with Content Controls

    What did you mean "I then need to update the "values of the controls on exiting the UserForm."? Did you mean that when the values of content control is changed, it should update the control on the user form which was open before?

    As far as I know, there is no such event suitable for this secnario. If you want content control to support this event, I suggest that you submit the feedback from the "Smile Face" at the top right corner of Word.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 6, 2015 6:19 AM
    Moderator