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. Paul Edstein 82,826 Reputation points Volunteer Moderator
    2022-06-22T03:18:57+00:00

    It works for me. Updated to unlock contents, too, though that shouldn't make any difference.

    0 comments No comments
  2. Anonymous
    2022-06-22T09:21:02+00:00

    Thank you so much Doug, its working

    Afzal

    0 comments No comments
  3. Paul Edstein 82,826 Reputation points Volunteer Moderator
    2022-06-22T09:35:40+00:00

    That may be, but Doug's code change adds nothing of value.

    0 comments No comments