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:
01261224
Views:
8
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform