Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Need macro to erase data when field is changed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LindaM - 15 Nov 2005 16:50 GMT
I've a document with fields in a protected section and a table for approvals
in an unprotected section.  When the 'Version' field is changed, I want some
of the cells in the approvals tables to be cleared. This is to prevent an
updated document slipping through without being re-approved. I'll also need a
message box to warn people what will happen if they play around with the
field.

I'm not very good with Word macros so your help is greatly appreciated.

Signature

Linda M

Greg - 15 Nov 2005 18:00 GMT
Linda,

I suppose that you could do this by setting the existing value of the
version field when a document is created then comparing this with the
value whenever a user exist the field.  You would have to save that
original value for comparison.  A docVariable could be used.

Something like:

Sub AutoNew()
ActiveDocument.Variables("Version").Value = "Original"
ActiveDocument.FormFields("Version").Result = "Original"
End Sub
Sub GetVerValue() 'set to run on entry to the Version field
ActiveDocument.Variables("Version").Value = _
 ActiveDocument.FormFields("Version").Result
End Sub
Sub CompareVerValue() 'Set to run on exit from the version field
If ActiveDocument.FormFields("Version").Result <> _
    ActiveDocument.Variables("Version").Value Then
 ActiveDocument.Tables(1).Cell(1, 1).Range = ""
 ActiveDocument.Tables(1).Cell(2, 1).Range = ""
 MsgBox "Revisions must be submitted for approval in accordance with
..."
End If
End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.