Search code examples
vbatextms-wordword-contentcontrol

How to get the text written in a Plain Text Content Control in Word via VBA


I still haven't understood how to use VBA in Word. I have a Plain Text Content Control, where our employees will write some text. This text will be added to an email. But how do I get this text? I would like something like this:

preparerText = ActiveDocument.ContentControls("PreparerText").Range.Text

But it doesn't work.

I have tried to Google how to do this, but cannot find an answer (or perhaps the answer is there, but I just don't understand how to use it in my context)

Information about the content control I want to get text from:
Information about the content control I want to get text from


Solution

  • Provided your content controls have unique titles it can be as simple as:

    preparerText = ActiveDocument.SelectContentControlsByTitle("PreparerText")(1).Range.Text