Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2015, 12:18 AM
Maskot Maskot is offline Updating/Locking FormFields Windows 7 64bit Updating/Locking FormFields Office 2007
Novice
Updating/Locking FormFields
 
Join Date: Jun 2015
Posts: 3
Maskot is on a distinguished road
Default Updating/Locking FormFields

Hi,
I need a help with WORD FormFields. I have a document with many formfields and I need to update all fields without two of them. One formfield shows amount in words so the field with this amount earlier cant be updated.
Could you please help? Macro below with problem on red. I need a part that will update each formfield separately.




Sub sbProtectSheet1()
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
ActiveDocument.Unprotect Password:=""
ActiveDocument.FormFields("qqq").Result = "XZX"
ActiveDocument.FormFields("wng").Result = "3000"
Dim dFormField As FormField
For Each dFormField In ActiveDocument.FormFields()
If dFormField.Name <> "wng" Then
dFormField.Update
End If
Next
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
ActiveDocument.Unprotect Password:=""
End Sub
Reply With Quote
  #2  
Old 06-24-2015, 12:30 AM
macropod's Avatar
macropod macropod is offline Updating/Locking FormFields Windows 7 64bit Updating/Locking FormFields 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

Why are you using a macro to update the fields, rather than just using their 'Calculate on Exit' property? As for selectively updating, that's only reliable if the fields concerned don't have any dependencies on other fields in the document, since other events, such as printing or previewing the document can also trigger updates.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 06-24-2015, 12:44 AM
Maskot Maskot is offline Updating/Locking FormFields Windows 7 64bit Updating/Locking FormFields Office 2007
Novice
Updating/Locking FormFields
 
Join Date: Jun 2015
Posts: 3
Maskot is on a distinguished road
Default

I know that I can update/calculate all FormFields at once but in this case I have dependencies between fields and some of them can't be updated. (Field with amount can't be updated after writing in it number because than field with amount in words will broke).
So I need macro that will update specific field or will update all but one or two. Do you know one?
Reply With Quote
  #4  
Old 06-24-2015, 01:48 AM
macropod's Avatar
macropod macropod is offline Updating/Locking FormFields Windows 7 64bit Updating/Locking FormFields 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

You are mistaken if you believe a field with an amount or text can be updated after writing in it via either the 'Calculate on Exit' property or via a general VBA .Fields.Update method. If someone can write in a Field, it cannot be dependent on any other field. In any event, as I already said:
Quote:
other events, such as printing or previewing the document can also trigger updates
This applies to auto-updating fields, such as DATE fields and to fields of any kind that reference other fields or document properties.

If your concern is to prevent a field that has already had some kind of user input from being edited, all you need do is change its type property to a 'Calculation' field.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 06-24-2015, 04:40 AM
Maskot Maskot is offline Updating/Locking FormFields Windows 7 64bit Updating/Locking FormFields Office 2007
Novice
Updating/Locking FormFields
 
Join Date: Jun 2015
Posts: 3
Maskot is on a distinguished road
Default

Yes you are right. Sorry for my mistake (work in a hurry).
You can delete this topic if You want. I have mixed few things.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating/Locking FormFields locking word table cells while auto-updating fields fingermouse Word 6 01-14-2015 06:22 AM
Updating/Locking FormFields Mailmerge and Formfields Liosis Mail Merge 4 03-07-2014 12:56 PM
Renaming Word Formfields: string too long error silverspr Word VBA 7 01-22-2013 06:20 PM
Updating/Locking FormFields Help with locking wdPictureContentControl remodel Word VBA 1 10-25-2012 10:45 PM
locking out word joe Word 0 11-19-2009 02:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:01 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