Quote:
Note that when you remove all content of that CC, it will display the placeholder text which may or may not suit your purposes. You can either edit the placeholder text or put a single space in the placeholder to avoid this problem
|
If you fill the content control with zero width space ChrW(8203) the control will completely disappear, but will still be present to be refilled with something else.
Code:
Sub Macro1
FillCC "MyCCTitle", ChrW(8203), True
End Sub
Code:
Public Sub FillCC(strCCTitle As String, strValue As String, bLock As Boolean)
'Graham Mayor - https://www.gmayor.com - Last updated - 03 Sep 2021
Dim oCC As ContentControl
On Error GoTo lbl_Exit
For Each oCC In ActiveDocument.ContentControls
With oCC
If .Title = strCCTitle Then
.LockContents = False
.Range.Text = strValue
.LockContentControl = True
.LockContents = bLock
Exit For
End If
End With
Next oCC
lbl_Exit:
Set oCC = Nothing
Exit Sub
End Sub