Word 2003 Form Field Formatting

D

David C

Is it possible to restrict the user from entering special characters in a
"regular text" form field? I want to restrict symbols and special characters
such as" !@#$%^&*
 
J

Jay Freedman

On Mon, 4 Jan 2010 16:15:01 -0800, David C <David
Is it possible to restrict the user from entering special characters in a
"regular text" form field? I want to restrict symbols and special characters
such as" !@#$%^&*

It isn't possible to prevent entry of those characters. What you can
do is check the entry as the cursor exits from the field, and send the
cursor back into the field if any of those characters are present.

Adapt the macros in http://www.gmayor.com/formfieldmacros.htm (and see
http://www.gmayor.com/installing_macro.htm if needed) by replacing the
AOnExit() macro with

Public Sub AOnExit()
Dim ch As String
Dim i As Long
With GetCurrentFF
For i = 1 To Len(.Result)
If Not Mid$(.Result, i, 1) Like "[A-Za-z0-9 .,]" Then
MsgBox "Enter only letters and numbers"
mstrFF = GetCurrentFF.Name
Exit For
End If
Next i
End With
End Sub
 
D

David C

Thank you for responding so quickly. Your solution is a little bit above my
expertiese. I will just add instructions for the user to stay away from
special characters to my document.

I have a follow-up question, if I may.

Is it possible to have the default "item" for a drop down box be blank? The
default for the drop down box that I set up is the item at the top of the
list.

Thanks

Jay Freedman said:
On Mon, 4 Jan 2010 16:15:01 -0800, David C <David
Is it possible to restrict the user from entering special characters in a
"regular text" form field? I want to restrict symbols and special characters
such as" !@#$%^&*

It isn't possible to prevent entry of those characters. What you can
do is check the entry as the cursor exits from the field, and send the
cursor back into the field if any of those characters are present.

Adapt the macros in http://www.gmayor.com/formfieldmacros.htm (and see
http://www.gmayor.com/installing_macro.htm if needed) by replacing the
AOnExit() macro with

Public Sub AOnExit()
Dim ch As String
Dim i As Long
With GetCurrentFF
For i = 1 To Len(.Result)
If Not Mid$(.Result, i, 1) Like "[A-Za-z0-9 .,]" Then
MsgBox "Enter only letters and numbers"
mstrFF = GetCurrentFF.Name
Exit For
End If
Next i
End With
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
.
 
J

Jay Freedman

Yes, just add an item at the top of the list whose value is a series
of nonbreaking spaces (entered with Ctrl+Shift+spacebar). Make it as
many spaces as needed to make the empty field have the desired width.

Thank you for responding so quickly. Your solution is a little bit above my
expertiese. I will just add instructions for the user to stay away from
special characters to my document.

I have a follow-up question, if I may.

Is it possible to have the default "item" for a drop down box be blank? The
default for the drop down box that I set up is the item at the top of the
list.

Thanks

Jay Freedman said:
On Mon, 4 Jan 2010 16:15:01 -0800, David C <David
Is it possible to restrict the user from entering special characters in a
"regular text" form field? I want to restrict symbols and special characters
such as" !@#$%^&*

It isn't possible to prevent entry of those characters. What you can
do is check the entry as the cursor exits from the field, and send the
cursor back into the field if any of those characters are present.

Adapt the macros in http://www.gmayor.com/formfieldmacros.htm (and see
http://www.gmayor.com/installing_macro.htm if needed) by replacing the
AOnExit() macro with

Public Sub AOnExit()
Dim ch As String
Dim i As Long
With GetCurrentFF
For i = 1 To Len(.Result)
If Not Mid$(.Result, i, 1) Like "[A-Za-z0-9 .,]" Then
MsgBox "Enter only letters and numbers"
mstrFF = GetCurrentFF.Name
Exit For
End If
Next i
End With
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
.
 

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