Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
How to toggle Protect Form in macros
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. |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
How to toggle Protect Form in macros
dickpaul wrote:
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 FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#3
Posted to microsoft.public.word.tables
|
|||
|
|||
How to toggle Protect Form in macros
This looks exactly what I needed. Thank you Jay.
"Jay Freedman" wrote: dickpaul wrote: 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 FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#4
Posted to microsoft.public.word.tables
|
|||
|
|||
How to toggle Protect Form in macros
Excellent job
"dickpaul" wrote: This looks exactly what I needed. Thank you Jay. "Jay Freedman" wrote: dickpaul wrote: 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 FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Radio or toggle buttons on a form using Word 03 tables | Tables | |||
Toggle form field between U.S. dollars and Euros | Microsoft Word Help | |||
How can I make a "Protect/Unprotect Document" toggle link? | Microsoft Word Help | |||
Making a form and the protect form is greyed out. What do I do? | Microsoft Word Help | |||
Protect form preventing all editing in document (how to limit form | Tables |