Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

Word 2003 FormFields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
VisualBasic@versatel.nl - 01 Apr 2006 19:19 GMT
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
David - 03 Apr 2006 16:02 GMT
Hello,

Maybe if you try ActiveDocument.FormFields(iBookMrkNm).Result = " "  as
below it can resolve you problem.

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
                   ActiveDocument.FormFields(iBookMrkNm).Result = " "
       End If
   End If

> Hello,
>
[quoted text clipped - 44 lines]
>
> VBA-er
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.