etech0
asked on
Refer to Plain Text Content Control in Word
I have a plain text content control in Word where a user enters data.
Can I reference that data later in the document?
The way I have it now, I bookmarked the control, but then the referenced data comes up with a control around it.
Is there a better way?
Thanks.
Can I reference that data later in the document?
The way I have it now, I bookmarked the control, but then the referenced data comes up with a control around it.
Is there a better way?
Thanks.
Without VBA, I don't think so. But does it matter? The control is only visible if clicked on, and doesn't appear in print.
ASKER
I know, but I don't want anyone to type in it, and the control makes it look like it should be typed in.
How can I do this with VBA?
How can I do this with VBA?
Give the content control, a unique Title, and put this code in the ThisDocument module:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim rng As Range
If ContentControl.Title = "MyContentControl" Then
Set rng = ActiveDocument.Bookmarks("MyBookmark").Range
rng.Text = ContentControl.Range.Text
ActiveDocument.Bookmarks.Add "MyBookmark", rng
End If
End Sub
ASKER
How do I give it a unique Title?
Select the control.
Click on the 'Design Mode' icon in the Controls group on the Developer tab.
Right-click on right-hand 'wing' of the control and choose properties. Enter the Title in the box.
Note that you can give more than one control the same title, so it is up to you to ensure that it is unique.
Note also that you can use the Tag property in the same way
Click on the 'Design Mode' icon in the Controls group on the Developer tab.
Right-click on right-hand 'wing' of the control and choose properties. Enter the Title in the box.
Note that you can give more than one control the same title, so it is up to you to ensure that it is unique.
Note also that you can use the Tag property in the same way
ASKER
I only have to do this once, and it will get stored in the document?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it. Thanks!