how to remove multiple content control in Word

Anonymous
2022-06-21T09:24:49+00:00

Hi,

I have standard word templates which has multiple "Rich Text Content Control", I want to apply some option in properties in each and every Rich Text Content Control. The properties options as below picture:

Show as: None

both option in locking

I would like to know that how to apply these options in each and every Rich Text Content Control at once?

Thanking you in advance,

Afzal

Microsoft 365 and Office | Word | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Doug Robbins - MVP - Office Apps and Services 322.1K Reputation points MVP Volunteer Moderator
    2022-06-22T06:29:44+00:00

    Use

    Dim CCtrl As ContentControl

    For Each CCtrl In ActiveDocument.ContentControls

    With CCtrl 
    
        Select Case .Type 
    
            Case wdContentControlRichText 
    
                If .LockContentControl = True Then 
    
                    .LockContentControl = False 
    
                End If 
    
            .Delete 
    
        End Select 
    
    End With 
    

    Next

    3 people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Paul Edstein 82,826 Reputation points Volunteer Moderator
    2022-06-21T09:54:55+00:00

    You could do that with a macro like:

    Sub Demo()

    Dim CCtrl As ContentControl

    For Each CCtrl In ActiveDocument.ContentControls

    With CCtrl

    Select Case .Type 
    
      Case wdContentControlRichText 
    
        .Appearance = wdContentControlHidden 
    
        .LockContentControl = True 
    
        .LockContents = True 
    
    End Select 
    

    End With

    Next

    End Sub

    For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm

    For Mac macro installation & usage instructions, see: https://wordmvp.com/Mac/InstallMacro.html

    3 people found this answer helpful.
    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-06-21T11:00:23+00:00

    Thank you very much macropod, its works perfectly, I would like to also know that if I want to remove all content control at once, means text remains but only content control remove, it it possible?

    Thanking you in advance,

    Afzal

    0 comments No comments
  2. Paul Edstein 82,826 Reputation points Volunteer Moderator
    2022-06-21T11:20:27+00:00

    Simply use:

    Sub DemoX()

    Dim CCtrl As ContentControl

    For Each CCtrl In ActiveDocument.ContentControls

    With CCtrl

    Select Case .Type 
    
      Case wdContentControlRichText 
    
       .LockContentControl = False
    
       .LockContents = False
    
       .Delete 
    
    End Select 
    

    End With

    Next

    End Sub

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2022-06-22T02:54:10+00:00

    Hi macropod,

    I tried your code but showing error as given below:

    Thanking you in advance,

    Afzal

    0 comments No comments