Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding FormFields to a word document
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01261174
Message ID:
01261229
Views:
9
>Can anyone help me with adding Formfields to a Word Document using automation? I am trying to scan a table and add formfields to a document with default text from the field in my table.
>
>The way that I generally do this is to create a Word Template (.dot) with Named BookMarks. If I name the bookmarks the same as the field in the table, the code to replace them is very simple:
>
>
>WITH This.oWord
>  *** Now replace all the bookmarks in the template.  Since we have set this up to have
>  *** the template names match the bookmark names, just loop though the bookmarks collection
>  *** and replace with the variable of the same name.
>  FOR EACH loBookMark IN .ActiveDocument.Bookmarks
>    lcVarName = loBookMark.Name
>    loBookMark.Range.Text = EVALUATE( ALLTRIM(lcVarName) )
>  ENDFOR
>ENDWITH
>
I second this approach. Users can compose their own letters to their liking. One thing with MSWord, it wont allow you to specify the same bookmark in more than one place. For example, if there's a rqmt to reference [LASTNAME] more than once in a DOC, you need to use a bookmark naming/numbering scheme of sorts for repeated bookmarks. [LASTNAME1] [LASTNAME2]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform