Need macro to erase data when field is changed

L

LindaM

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.
 
G

Greg

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top