Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-15-2011, 04:59 AM
PosseJohn PosseJohn is offline Preventing Form Fields to Reset Windows XP Preventing Form Fields to Reset Office 2007
Novice
Preventing Form Fields to Reset
 
Join Date: Jul 2011
Posts: 20
PosseJohn is on a distinguished road
Default Preventing Form Fields to Reset

Greetings,



I have a WORD document that contains Form Fields for the user to enter information. This document is repeatedly used from one shift to another, it contains information for shift turnover.

I want to FORCE the user to enable macros so that when the user closes the document, it automatically creates a 'archive' copy of the file, with the current date/time in the file name, saved to a different folder, for retrieval if something got fouled up.

I attempted to protect the document from any changes upon closing, and then upon opening, I would unprotect the document, then re-protect it allowing 'Filling in forms'.

When I do this, all the fields reset to empty.

I don't want the user to have to retype everything, only edit what might have changed in the last shift, then save it.

Here is my code:

Code:
 
Private Sub Document_Close()
        With ThisDocument
            .Unprotect Password:="pw"
            .Protect Password:="pw", _
                    NoReset:=False, _
                    Type:=wdAllowOnlyReading, _
                    UseIRM:=False, _
                    EnforceStyleLock:=False
        End With
End Sub
Code:
 
Private Sub Document_Open()
        With ThisDocument
            .Unprotect Password:="pw"
            .Protect Password:="pw", _
                    NoReset:=False, _
                    Type:=wdAllowOnlyFormFields, _
                    UseIRM:=False, _
                    EnforceStyleLock:=False
        End With
End Sub
Reply With Quote
  #2  
Old 07-15-2011, 07:31 PM
macropod's Avatar
macropod macropod is offline Preventing Form Fields to Reset Windows 7 64bit Preventing Form Fields to Reset Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi PosseJohn,

Change 'NoReset:=False' to 'NoReset:=True'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-15-2011, 09:25 PM
PosseJohn PosseJohn is offline Preventing Form Fields to Reset Windows XP Preventing Form Fields to Reset Office 2007
Novice
Preventing Form Fields to Reset
 
Join Date: Jul 2011
Posts: 20
PosseJohn is on a distinguished road
Default

Thankyou, setting the NoReset:=True now prevents the form fields from going blank.

Followup question:
Using the code I previously posted, it seems that the VBA code doesn't protect the document after AllowOnlyReading. When I reopen the document, without enabling macros, the FormFields are still able to be edited.

When troubleshooting, I stepped thru the VBA code by using F8, and the code seemed to work just fine. But when the code runs on its own, it doesn't.

Any suggestions? Thanks!!
Reply With Quote
  #4  
Old 07-15-2011, 09:42 PM
macropod's Avatar
macropod macropod is offline Preventing Form Fields to Reset Windows 7 64bit Preventing Form Fields to Reset Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi PosseJohn,

What you need to do is to lock each formfield. For example:
Code:
Private Sub Document_Close()
Dim fFld As FormField, Pwd As String
Pwd = "pw"
With ThisDocument
  .Unprotect Password:=Pwd
  For Each fFld In .FormFields
    fFld.Enabled = False
  Next
  .Protect Password:=Pwd, NoReset:=True, _
    Type:=wdAllowOnlyFormFields, _
    UseIRM:=False, EnforceStyleLock:=False
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 07-15-2011, 09:44 PM
PosseJohn PosseJohn is offline Preventing Form Fields to Reset Windows XP Preventing Form Fields to Reset Office 2007
Novice
Preventing Form Fields to Reset
 
Join Date: Jul 2011
Posts: 20
PosseJohn is on a distinguished road
Default

Very well, I will give it a go. Thank you for your quick response and sharing of the knowledge.

G'Day
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing Form Fields to Reset Tab through fields on a form. Keep on Ticking Word 1 06-23-2011 03:29 AM
Calculating Form Fields in Microsoft Word wubba80 Word 1 06-25-2010 12:42 AM
Form Fields Problem shogan Word 1 05-18-2010 01:01 AM
Form fields in Word messed up mba Word VBA 0 02-07-2010 09:54 PM
Form Fields questions Word 0 04-27-2009 10:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft