Run macro on Exit of a Text form Field

B

BJ

I am using a 'Text form Field' in a word template for user to enter a date.
and set up to run a macro when user exit from this text form field.

it works fine on my machine. either tab out from the field or click on
somewhere else. the header will be changes based on the date i entered. but,
on a user's machine, the macro didn't run the first time user tab out the
field. user has to go back to the field and tab out again to trigger the
macro.

can someone let me know why this hapened? is this because the user has
different settings or what?

Thank you for any help.
 
G

Graham Mayor

What does the macro do? Post the code?
Is the form locked on the user's PC?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

BJ

The document which is created from the test.doc is a protected document. here
is the code:
*******************************
Sub CheckValidDate()
On Error Resume Next

Set thisDoc = Application.ActiveDocument

If thisDoc.FormFields("txtThisDate").result = "" Then
MsgBox "Please Enter the ""Date This Appraisal"" Field.", vbOKOnly +
vbExclamation, _
"Missing Information Message"
thisDoc.FormFields("txtThisDate").Select
End
Else
If CDate(thisDoc.FormFields("txtThisDate").result) >
CDate("12/24/2006") Then
blNewPro = True
Call ShowNewPACE
Else
blNewPro = False
If blFirstTime = True Then
blFirstTime = False
Else
Call ShowOldPACE
End If
End If
End If

If thisDoc.FormFields("txtLastDate").result = "" Then
MsgBox "Please Enter the ""Date Last Appraisal"" Field.", vbOKOnly +
vbExclamation, _
"Missing Information Message"
thisDoc.FormFields("txtLastDate").Select
End
ElseIf CDate(thisDoc.FormFields("txtThisDate").result) <= _
CDate(thisDoc.FormFields("txtLastDate").result) Then
MsgBox """Date This Appraisal"" must be greater than ""Date Last
Appraisal"".", vbOKOnly + vbExclamation, _
"Invalid Information Message"
thisDoc.FormFields("txtThisDate").Select
End If

End Sub
*******************

It's called when exit the text form fileld.

Thanks.
 
D

Doug Robbins - Word MVP

The user may have the macro security level set to high and if test.doc is
not in a trusted location, the macros in it would be automatically disabled.
Test.doc should be saved as a template (.dot file) and then should be copied
into the user template folder or the workgroup template folder and the use
should use File>New and then select the template as the basis for the
document that they want to create. That way, the macros in the template
will be available for use in the new document that the user creates.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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