Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
dickpaul dickpaul is offline
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.word.tables
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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   Report Post  
Posted to microsoft.public.word.tables
dickpaul dickpaul is offline
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.word.tables
dickpaul dickpaul is offline
external usenet poster
 
Posts: 3
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio or toggle buttons on a form using Word 03 tables Tina Fish Tables 1 January 23rd 08 05:21 PM
Toggle form field between U.S. dollars and Euros Lenny Microsoft Word Help 1 June 2nd 07 06:38 AM
How can I make a "Protect/Unprotect Document" toggle link? JustSomeGuy Microsoft Word Help 2 December 13th 06 01:17 PM
Making a form and the protect form is greyed out. What do I do? John Microsoft Word Help 1 June 9th 05 03:56 AM
Protect form preventing all editing in document (how to limit form TJ Tables 2 May 17th 05 10:31 PM


All times are GMT +1. The time now is 03:20 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"