Stacy
Now my problem is not to open a datasource.
I'm able to open 3 kind of datasources : Excel, DBF and .OCD (Office Database Connection used to wrap à ODBC Foxpro files).
My actual trouble (the same that in January) is when I put some merge fields in the header or the footer.
In "design time" in Word, all is OK but programatically from Visual FoxPro 7/8 it does not work.
I can see all the merge fields in the body of the Word (XP and 2003) document but not in the header and / or the footer.
This morning, I discover a very strange thing.
If I put the same string (i.e "HELLO") in the body, header and footer and I use the function "Replace" to replace "HELLO" by "OLLEH" : It works fine.
If I create a macro to do the same thing, it works only in the body.
I will invertigate in this way because I think that all my troubles come from here.
I everybody
>Copy this code to a prg and run... Syntax seems to work for me under Word 2000,XP and 2003.
>
>
>oword=crea('word.application')
>oword.visible=.t.
>oword.documents.open('C:\MYFILE.doc')
>oword.APPLICATION.activedocument.mailmerge.OpenDataSource('c:\MYFILE.xls',,,.T.,,,,,,,,"Entire Spreadsheet")
>
>
>
>Another thing I am doing is having a template document file already created on the customer machine. If c:\myfile.doc does not exist, my program just copies the template doc to the new document name before this code runs...
>Then, the code will open the datasource specified using a pre-built 'word-merge' document.