Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2013, 06:57 AM
Catty Catty is offline Disabling content controls and protecting document sections. Windows 7 32bit Disabling content controls and protecting document sections. Office 2010 32bit
Advanced Beginner
Disabling content controls and protecting document sections.
 
Join Date: Nov 2013
Posts: 39
Catty is on a distinguished road
Default Disabling content controls and protecting document sections.

Hi,

I am creating a macro to disable certain sections of a document (document has a lot of content controls and thus have to disable them aswell).
After running this macro, my doc is still not protected. Any idea what I'm doing wrong? Below is the code.



Code:
Sub DisableDoc()
  
  'locking the content controls
  
   Dim ofmfld As FormField, CCtrl As ContentControl
        With ActiveDocument
            For Each ofmfld In .FormFields
                ofmfld.Enabled = False
            Next
            For Each CCtrl In .ContentControls
                CCtrl.LockContentControl = False
            Next
       
        End With

     Selection.InsertBreak Type:=wdSectionBreakContinuous       
    ActiveDocument.Sections(1).ProtectedForForms = False
    ActiveDocument.Sections(2).ProtectedForForms = True
    ActiveDocument.Sections(3).ProtectedForForms = True
    ActiveDocument.Sections(4).ProtectedForForms = True
    ActiveDocument.Sections(5).ProtectedForForms = True
    ActiveDocument.Sections(6).ProtectedForForms = True
        
End Sub
Reply With Quote
  #2  
Old 11-22-2013, 11:21 AM
gmaxey gmaxey is offline Disabling content controls and protecting document sections. Windows 7 32bit Disabling content controls and protecting document sections. Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Catty,

Why are you using formfields and content controls in the same document? No law against it, but you would probably be better off to use one or the other and the one to use IMHO is clearly the content control.

See: http://gregmaxey.com/word_tip_pages/...llin_form.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 11-29-2013, 05:10 AM
Catty Catty is offline Disabling content controls and protecting document sections. Windows 7 32bit Disabling content controls and protecting document sections. Office 2010 32bit
Advanced Beginner
Disabling content controls and protecting document sections.
 
Join Date: Nov 2013
Posts: 39
Catty is on a distinguished road
Default

Hi Greg,

Thanks for the response.

Just to provide feedback. I had to first lock the entire document and then unlock just the specific section I needed to edit.

Code:
With ActiveDocument
          .Protect Password:="", NoReset:=False, Type:=wdAllowOnlyReading, useirm:=False, EnforceStyleLock:=False
          .Sections(1).Range.Editors.Add (Word.WdEditorType.wdEditorEveryone)

End With
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling content controls and protecting document sections. VBA to set Content controls as non printing Sammie0Sue Word VBA 21 01-12-2021 04:44 PM
Disabling content controls and protecting document sections. Content Controls Sammie0Sue Word 6 11-06-2013 10:56 PM
Using both rich and plain content controls in one document Erica.Black Word 0 06-18-2013 10:33 AM
Macro to link 2 content controls bortonj88 Word VBA 2 08-21-2012 06:24 AM
Disabling content controls and protecting document sections. Grouping Content Controls cksm4 Word VBA 2 03-01-2011 12:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft