Open UserForm when form field is blank

H

hlock

How would program Word to open a user form whenever a user enters or clicks
on an empty formfield, but not open the user form when the formfield is not
blank.
 
J

Jean-Guy Marcil

hlock was telling us:
hlock nous racontait que :
How would program Word to open a user form whenever a user enters or
clicks on an empty formfield, but not open the user form when the
formfield is not blank.

You could do it like this:

Use this macro in the onEntry event of the text formfield:

'_______________________________________
Sub RunMacro()

With Selection
If .Paragraphs(1).Range.FormFields(1).Result = "" Then
MyUserFormShow
Else
MsgBox "Do not do anything."
End If
End With

End Sub
'_______________________________________

Which will call this macro if it is empty:

'_______________________________________
Sub MyUserFormShow()

Dim myForm As frmToShow

Set myForm = New frmToShow
myForm.Show

Unload myForm
Set myForm = Nothing

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site: http://www.word.mvps.org
 
Top