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 / May 2006

Tip: Looking for answers? Try searching our database.

Bookmark check

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frenk Nijssen - 19 Apr 2006 19:54 GMT
Hi,

I have created a form as a word template, when the user wants to print the
form i would like to check if he filled in the mandatory Formfields.

Is there code available to do this in a loop? all Formfields are bookmarked,
the ones that i like to check if they are filled out, end with "_man"

Further i would like to point the user to the formfield that he hasn't
filled out with a Msgbox "MyFormfieldname - _man".

I am fairly new at this, so if anyone can point me in the right direction
that would by great.

Thanks
Frenk
Jean-Guy Marcil - 19 Apr 2006 21:59 GMT
Frenk Nijssen was telling us:
Frenk Nijssen nous racontait que :

> Hi,
>
[quoted text clipped - 11 lines]
> I am fairly new at this, so if anyone can point me in the right
> direction that would by great.

Try this:

'_______________________________________
Sub FilePrint()

   'To intercept File > Print and CTRL-P
   If AllFormfieldsOK Then
       Dialogs(wdDialogFilePrint).Show
   End If

End Sub
'_______________________________________

'_______________________________________
Sub FilePrintDefault()

   'To intercept the Standard toolbar button
   If AllFormfieldsOK Then
       ActiveDocument.PrintOut
   End If

End Sub
'_______________________________________

'_______________________________________
Private Function AllFormfieldsOK() As Boolean

Dim myFormField As FormField

AllFormfieldsOK = True

For Each myFormField In ActiveDocument.FormFields
   'Only check formfields that are mandatory
   'use LCase in case "_Man" was used in text
   If LCase(Right(myFormField.Name, 4)) = "_man" Then
       'Use Trim in case there are spaces and no other character
       If Trim(myFormField.Result) = "" Then
           MsgBox "You must enter information in this field.", _
               vbExclamation, "Data missing"
           myFormField.Range.Fields(1).Result.Select
           AllFormfieldsOK = False
           Exit Function
       End If
   End If
Next

End Function
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Frenk Nijssen - 19 Apr 2006 23:32 GMT
Thanks a lot Jean-Guy,

Perfect piece of code, works as a delight.

Cheers
Frenk

> Frenk Nijssen was telling us:
> Frenk Nijssen nous racontait que :
[quoted text clipped - 63 lines]
> End Function
> '_______________________________________
Jean-Guy Marcil - 20 Apr 2006 06:31 GMT
Frenk Nijssen was telling us:
Frenk Nijssen nous racontait que :

> Thanks a lot Jean-Guy,
>
[quoted text clipped - 77 lines]
>> jmarcilREMOVE@CAPSsympatico.caTHISTOO
>> Word MVP site: http://www.word.mvps.org

Glad to be of service!

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Edwin - 16 May 2006 15:42 GMT
Yo Frenk,

How's life..?

dwin.

> Hi,
>
[quoted text clipped - 12 lines]
> Thanks
> Frenk
 
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.