Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding FormFields to a word document
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01261174
Message ID:
01261224
Vues:
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform