Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Required Text Box
Is there a way to make a field required on a form? e.g., prevent a user from
saving a form if a particular field is left blank and displaying a message telling the user which field needs to be completed. Thanks for your help. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Required Text Box
Hi TechWriter,
A macro could be used to do this but, if the user's security settings are too high, or the users elects to disable macros in the document, then the macro approach won't work. The following macro, when placed in the document's €˜ThisDocument module, prevents the document being closed if it contains any formfields that have not been filled in: Private Sub Document_Close() Dim aField As FormField For Each aField In ActiveDocument.FormFields If Trim(aField.Result) = "" Then MsgBox "Please complete all the items" ThisDocument.Reload Exit Sub End If Next aField End Sub You can the following version to check a specific formfield by referencing the field's bookmark name (assuming you've set its properties to create one): Private Sub Document_Close() If Trim(ActiveDocument.Bookmarks("BkMrk").Range.Text) = "" Then MsgBox "Please complete the nominated item." 'ThisDocument.Reload Exit Sub End If End Sub where 'BkMrk' is the name of the bookmark. Change the message to suit. Cheers -- macropod [MVP - Microsoft Word] ------------------------- "TechWriter" wrote in message ... Is there a way to make a field required on a form? e.g., prevent a user from saving a form if a particular field is left blank and displaying a message telling the user which field needs to be completed. Thanks for your help. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Making text fields required | Microsoft Word Help | |||
How can I specify that a text field be required? | Microsoft Word Help | |||
Text box as a required field | Microsoft Word Help | |||
Help required ??? | Microsoft Word Help | |||
Help required..... | Microsoft Word Help |