Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I open a

Status
Not open for further replies.

tgorrie

Programmer
May 8, 2001
13
US
Microsoft Word Document from a VisualFoxpro 6.0 .pjx?
 
Here's a simple program I wrote or copied from somewhere(possibly a help file example):

Code:
USE customers
public oWord
oWord=CREATEOBJECT("Word.Basic")
scan 
oWord.FileOpen ("MyLetter.doc")
oWord.EditGoto("Contact")
oWord.Insert(customers.Contact)
oWord.EditGoTo("Company")
oWord.Insert(customers.Company)
oWord.FilePrint
wait window 'Printing please wait...' timeout(3) 
oWord.Fileclose(2)
endscan
oWord.AppClose()
release oWord

This program does a text merge to a form letter. It should at least give you an idea of how to do things. If you need more help, give a more detailed question. --Dave
 
I am trying to automate my Mail Merge process using Word document and a VFP database. Presently when I use code similar to what DODMED's thread 184-81165 reply, the name that I want to insert i.e. Dear (then Full_name) the name prints at the top of the page, about an inch down and about an inch from the left margin. I want it to print about 17 lines down, and about an and inch and one half from the left side. Any ideas????
 
The thing is that the example I gave is for a preexisting form letter. It will have had tags like "Contact" already placed in the letter at specific points in the letter. Then when you do a .editgoto the cursor goes to whatever spot that tag points to. Then the .insert puts in the value of your .dbf field. They you repeat until you've inserted all the fields where you want them. Now if you really want to dig into completely writing a letter from scratch, you need to look at the vba help file for Word and see what you need to do (The help file will have a name like "vbawd10.chm". Open that up and look around. If you have questions on how to translate VBA into VFP just ask and someone should be able to answer). Otherwise just prepare the word document you want including the bookmarks you want. Then open it for editing using the code above. Dave Dardinger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top