• Extract value of a content control using VBA in Word

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Extract value of a content control using VBA in Word

    Author
    Topic
    #491213

    We have set up some building block content controls in tables (in Word 2010) for the users to select a status (High, Medium, Low).
    We used building blocks rather than dropdown lists so that we could format the values in specific colours.
    Now I want to run a macro that scrolls through the whole document and pulls out information from these many tables and displays a summary elsewhere.
    Most info I can grab but I cannot work out how to get the value of one of these controls from VBA (it returns “/” instead of High/Medium/Low or even a number).
    If I use a dropdown list instead I can get the status value in a macro.

    So can you help me work out what methods to use to get the value of a building block content control?

    Alternatively, can I somehow use conditional formatting – if a dropdown value is “High”, make it red, Amber if medium, and green for low?

    thanks,
    Margaret

    Viewing 1 reply thread
    Author
    Replies
    • #1414840

      See attached, which uses a dropdown with conditional formatting (I already had this example to hand). As coded, it shades the table cell the dropdown control is in. If you want to shade only the actual content control, simply delete the ‘.Cells(1)’ references.

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1414845

      Thanks Paul – this is great.

    Viewing 1 reply thread
    Reply To: Extract value of a content control using VBA in Word

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: