![]() |
|
|
|
#1
|
|||
|
|||
|
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
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
VBA to set Content controls as non printing
|
Sammie0Sue | Word VBA | 21 | 01-12-2021 04:44 PM |
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 |
Grouping Content Controls
|
cksm4 | Word VBA | 2 | 03-01-2011 12:46 PM |