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

Word 2002 foxpro connection string

Status
Not open for further replies.

derren

Programmer
Mar 22, 2001
500
GB
I have been using Fox6 automation to create a mailmerge wizard using my fox database into Word 2000. All was going swimmingly until I tried it on Word 2002 - d'oh! The connection seems to be different, as Word is using ODC (office data connection, I think). I have tried all sorts of permutations of the connection values, but to no avail.

As this is going into my distributed software I am trying to avoid DSN connections, but any help would be greatly appreciated.

Currently my (successful) mailmerge code is

Code:
* sqltext is the generated sql code
* sql2 is the other part of the sql if it is longer than 255 chars
* mergepath is the path to the folder containg the data
mtable  = mergepath + "mailmerge.DBF"
msource = "DSN=FoxPro Files - Word;SourceDB=" + folder containing table + ";SourceType=DBF;"
odocument.mailmerge.OpenDataSource(mtable,0,.f.,.f.,.t.,.f.,"","",.f.,"","",msource,sqltext,sql2)

If anyone has done a successful Word 2002 merge using automation, can you shed any more light on what I would need to connect once more?

Thanks
Derren
[Mediocre talent - spread really thin]
 
derren

Is there a reason why you do not use :
Code:
o=CREATEOBJECT("word.application")
myDoc=o.Documents.add()
myDoc.MailMerge
etc...Or am I missing something...
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
derren

Take a look at faq184-2410. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks for responding

My application is a wizard so that my users can interrogate their data using simple questions - which schools, gender, fess paid, data order, which fields to show, grade, age range, etc.

This creates a query which is injected into a Word file of their choice (new or existing) so that they never need to scratch their heads trying to get a mailmerge to work (especially as the data they will want to see is in multiple tables!) All they then need to do is put the fields into their document where they want, tweak their words/layout and press the merge button.

These mailmerges can be saved by the user, so that they can apply the same criteria to another file whenever they like. These can be loaded into an existing document and they can even open a saved mailmerged file and all of the criteria which created the file are loaded into the wizard. I am really happy with it, as are my technophobic testers, who think it is the dog's proverbials!

So just creating a document which the user still needs to find the data, choose the datasource etc. isn't what I was after - but I can why you suggested it, and am thankful that you did.

After much investigation, and a tranche of the usual trial and error logical testing the actual answer is:

Code:
* sqltext is the generated sql code
* sql2 is the other part of the sql if it is longer than 255 chars
* mergepath is the path to the folder containg the data
* the database containing the table is called "mm.dbc"
* the table is called "mailmerge.dbf"

mtable  = mergepath + "mailmerge.DBF"
msource = "DSN=Visual FoxPro Database;SourceDB=" + mergepath + "mm.DBC;SourceType=DBC;"
odocument.mailmerge.OpenDataSource(mtable,0,.f.,.f.,.t.,.f.,"","",.f.,"","",msource,sqltext,sql2)

This is compatible with Word 2000 and Word 2002, but as yet I am struggling with 97 - but it will happen.

Thanks again for your help Derren
[Mediocre talent - spread really thin]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top