View Single Post
 
Old 08-17-2020, 11:26 AM
GDixit GDixit is offline Windows 10 Office 2010
Novice
 
Join Date: Aug 2020
Posts: 2
GDixit is on a distinguished road
Default VBA, Allow only Form Fields to edit in MSword

I am trying to write a macro, which should restrict any changes to Form except allowing content control properties.

I tried this macro, it does work and allows modification only to form fields(content control properties), however takes away capabilities to insert any image or table in these content control properties.

Sub Protect_FormFields()
'
' Protect_FormFields Macro
'
'
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True
End If

End Sub


I need the option to add a table. If I manually select all form fields -> restrict editing -> select 'allow only this type of editing in the document' -> under exception select 'everyone' -> yes, start enforcing protection => then it works as expected ( allows only form fields editing & still can add table/image to form fields).

I am struggling to write a generic loop which should select all content control properties & then explicitly allow only selection for modification in a document

Selection.Editors.Add wdEditorEveryone

and apply below code on the rest of document.

ActiveDocument.Protect Password:="", NoReset:=False, Type:= _
wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False


I will really appreciate help/pointers to proceed
Reply With Quote