Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MS WORD Doc values
Message
From
09/11/2006 07:49:51
 
 
To
08/11/2006 23:19:36
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01168338
Message ID:
01168390
Views:
12
Hi

One easy way to do this is add Word bookmarks in each place you want to add text and save the document as a template then you can run code like this:

oWord= createobject("word.application")
oWord.Options.ReplaceSelection = .t. && Replace selection

* Create a new document based on the template

oDocument = oWord.Documents.add("template.dot")

setvalue(oDocument, "Name", "Mr A Person")
setvalue(oDocument, "Add1", "1 North Lane")
setvalue(oDocument, "Town", "Atown")
setvalue(oDocument, "County", "Surrey")
setvalue(oDocument, "LetterDate", cdow(date()) + " " + dmy(date()))
setvalue(oDocument, "Signatory", "Mr Banana")

* Save, print, whichever

procedure setvalue(oDocument, cBookmark, cValue)

oBookmark = oDocument.Bookmarks(cBookmark)
oBookmark.select
oDocument.application.selection.TypeText(cValue)

endproc
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform