Clear a Locked Word Content Control Without Deleting It
Question details
Clear the text in a Word rich-text content control with VBA while preserving the control and positioning the cursor for new text.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A macro needs to find a content control by title, clear its existing text, and let the user enter replacement text.
- Observed behavior
- The macro fails when the content control's contents are locked.
In Word, enable the Developer tab if necessary, then select the control and open Developer > Properties to check its title and locking settings. The VBA title comparison is case-sensitive.
Clear the content control by title with Word VBA
Use this macro to unlock the control's contents, clear its text, prevent deletion of the control, and place the cursor inside it.
A control can be protected against deletion while its contents remain editable. To let the user type after the macro runs, the macro leaves the contents unlocked.
The macro targets the first rich-text control whose title exactly matches the specified title.
In Word, open Developer > Visual Basic. In the VBA editor, select Insert > Module.
Paste this code into the module and replace MyControlTitle with the exact title from the control's Properties dialog: Sub ClearContentControlText() Dim cc As ContentControl Dim insertionPoint As Range For Each cc In ActiveDocument.ContentControls If cc.Title = "MyControlTitle" And cc.Type = wdContentControlRichText Then cc.LockContents = False cc.LockContentControl = True cc.Range.Text = "" Set insertionPoint = cc.Range.Duplicate insertionPoint.Collapse Direction:=wdCollapseStart insertionPoint.Select Exit Sub End If Next cc MsgBox "Matching rich-text content control not found." End Sub
Save a document containing the macro as a Word Macro-Enabled Document (.docm), or save a template containing it as a Word Macro-Enabled Template (.dotm). In Word, select Developer > Macros, choose ClearContentControlText, and select Run.
Edit Word Documents with WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. Its format compatibility helps you move existing files into WPS, though it does not fix Word-specific VBA locking issues.

Frequently Asked Questions
Why does the macro say the content control is locked?
The control's contents may be locked. Select it in Word and open Developer > Properties to inspect the locking settings. The macro sets LockContents to False before clearing the text.
How do I prevent users from deleting the control but still let them type?
In Developer > Properties, enable the option that prevents deletion of the content control, but leave its contents unlocked. In VBA, the corresponding settings are LockContentControl = True and LockContents = False.
Why can't the macro find my content control?
Open Developer > Properties and check the control's Title. The macro compares the title case-sensitively and only matches rich-text content controls.
What file format should I use for the macro?
Use File > Save As and choose .docm for a macro-enabled document or .dotm for a macro-enabled template.




