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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP AND Word Mail Merge

Status
Not open for further replies.

stuartmckay

Programmer
Dec 4, 2006
13
CA
I am working on adding mail merge functionality to our VFP application. I have been playing with bookmarks and have been successful at navigating thru a document that has existing bookmarks and replacing the book mark with the appropriate information. What I have not been able to figure out is how to automate the creation of the initial template document. Basically how do I popup a list of the different bookmarks such as custname, address, phone etc. that the user can pick from and add into the new word doc template that they create.

 
Code:
oselection=oword.selection
oselection.bookmarks.add("one")

will add the bookmark "one" to the document at the point of insertion.

Pondering your question, would you not be better
1.setting up a master template with bookmarks you use for insertion points

2.get the list of which ones you want to add to the current
custom report

3. navigate to the appropriate master bookmarks

4. insert the bookmarks you want to put in this report

fill with data for the custom report
wjwjr
 
Yes, I am not looking to provide the user with a list of bookmarks that will be available to them to insert into a document. I am just not sure how to build and display this type of list.
 
I have ruled out the use of bookmarks due to the limitation of the bookmark to exist only once in a document. This makes sense and was pointed out to me in the msdn forum.
 
Stuart,

I have ruled out the use of bookmarks

That'a a good move. I once tried to use bookmarks to do a mailmerge. It was OK as long as the requirements were simple, but I soon realised it was not the way to go.

I do use Word's own mailmerge features. This works much better.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike

Using this concept when the user creates the template document are you popping up a list of the field names that they can select?

Stuart
 
Stuart,

If you create a sample datasource and attach it to the Word document, the list of fields will be available to the user from within Word while they are creating the merge document. For production purposes, I detach the data source from the template document. Then at runtime, I create the datasource, open the document, attach the data source and merge.

pamela
 
What I ended up doing is a combination of using VFP and the word object model plus creating and running word macros. This solution seems to work well and allows me to leverage off some work that was done in the foxpro 2.6 app that is being ported to VFP.

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top