Discussion:
Word 2003 FormFields
(too old to reply)
V***@versatel.nl
2006-04-01 18:19:35 UTC
Permalink
Hello,

Does anyone knows how to erase the value of a FormField in Word with Office
2003?

When I am using the code as membered (sending an empty string) below I get
an error and the FormField is still having it's value.

'= BEGIN CODE
Public Function WriteDocFds(iBookMrkNm, iVal) 'Office2003
On Error GoTo errHandler

Set ffield = ActiveDocument.FormFields(iBookMrkNm).TextInput

If ffield.Valid = True Then
If iValue <> "" And iValue <> " " Then
ffield.Default = iVal
Else
If iVal = "" Then ffield.Default = " " 'HERE I AM
USING SPACE TO EMPTY IT BUT SOMETIMES IT REALLY
NEEDS TO BE EMPTY
End If
End If

Exit Function

errHandler:
Select Case Err.Number
Case 438
'NOTHING
Case 4198
'NOTHING
Case 5101
'NOTHING
Case 5941
'NOTHING
Case Else
MsgBox "WriteDocuFields" & vbCrLf & Err.Description, vbCritical,
"Fout#: " & Err.Number
End Select
End Function


'= END CODE
Thanks a lot in advance!

VBA-er
Charles Kenyon
2006-04-01 19:58:51 UTC
Permalink
I would suggest that all responses be posted in the vbabeginners newsgroup.
(This has been posted multiple times is the vba groups.) In the Microsoft
Word newsgroups it is considered bad form to post separate messages to
multiple newsgroups. If you need to post in more than one forum (unusual)
please post a single message with both forums in the header of that single
message. That way (1) your question and the various answers stay together,
(2) less space is used on the news servers, (3) less bandwidth is used on
the Internet, (4) you only have to check one forum for answers that appear
in both forums, and (5) you won't unnecessarily annoy the people you are
asking for help. This isn't meant to criticize you. We were all beginners
once and the only way to learn is to try. (BTW, a number of the Microsoft
newsgroups don't want posting in more than one newsgroup, period. Check the
FAQ.)
Take a look on the MVP FAQ website under "getting help" for more reasons ase
well as other suggestions for getting answers more easily and quickly. <URL:
http://www.mvps.org/word/FindHelp/Posting.htm>
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by V***@versatel.nl
Hello,
Does anyone knows how to erase the value of a FormField in Word with Office
2003?
When I am using the code as membered (sending an empty string) below I get
an error and the FormField is still having it's value.
'= BEGIN CODE
Public Function WriteDocFds(iBookMrkNm, iVal) 'Office2003
On Error GoTo errHandler
Set ffield = ActiveDocument.FormFields(iBookMrkNm).TextInput
If ffield.Valid = True Then
If iValue <> "" And iValue <> " " Then
ffield.Default = iVal
Else
If iVal = "" Then ffield.Default = " " 'HERE I AM
USING SPACE TO EMPTY IT BUT SOMETIMES IT REALLY
NEEDS TO BE EMPTY
End If
End If
Exit Function
Select Case Err.Number
Case 438
'NOTHING
Case 4198
'NOTHING
Case 5101
'NOTHING
Case 5941
'NOTHING
Case Else
MsgBox "WriteDocuFields" & vbCrLf & Err.Description, vbCritical,
"Fout#: " & Err.Number
End Select
End Function
'= END CODE
Thanks a lot in advance!
VBA-er
Loading...