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 / March 2008

Tip: Looking for answers? Try searching our database.

Run macro on Exit of a Text form Field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BJ - 20 Mar 2008 16:35 GMT
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.
Graham Mayor - 21 Mar 2008 13:17 GMT
What does the macro do? Post the code?
Is the form locked on the user's PC?

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> 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
[quoted text clipped - 10 lines]
>
> Thank you for any help.
BJ - 24 Mar 2008 15:07 GMT
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.

> What does the macro do? Post the code?
> Is the form locked on the user's PC?
[quoted text clipped - 13 lines]
> >
> > Thank you for any help.
Doug Robbins - Word MVP - 24 Mar 2008 21:03 GMT
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.

Signature

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

> The document which is created from the test.doc is a protected document.
> here
[quoted text clipped - 67 lines]
>> >
>> > Thank you for any help.

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.