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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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