dickpaul said:
I have a macro to add a line to a table on a template. It works when
I click Protect Form button and click Protect Form again after the
macro completes. I want to toggle the button in the macro so I don't
have to do it manually.
Depending on whether you've added a password to the form protection, use one
of these arrangements:
Sub Whatever()
' unprotect
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
' do whatever you need here
' reprotect without emptying the fields
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End Sub
Sub WhateverWithPassword()
Const myPassword = "asdf1234"
' unprotect
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=myPassword
End If
' do whatever you need here
' reprotect without emptying the fields
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True, Password:=myPassword
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.