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!

Unable to open data source Visual Foxpro / Word XP

Status
Not open for further replies.

PaulHerschell

Programmer
Oct 9, 2001
59
NL
I am having a problem mailmerging Visual FoxPro 6 with Word XP resulting in a '1429 OLE IDispatch exception code 0 from Microsoft Word: Word was unable to open the data source' error.

The curious thing about this error is that the mailmerge works fine on Word 2000, it also works fine on Word XP systems that have been upgraded from Word 2000 like my own system, however, I have had a number of customers that have upgraded from Word 97 to Word XP or just installed Word XP for the first time who get the error message.

My first thought was a problem with the ODBC drivers. I compared the machines to my own working machine and the Visual FoxPro Tables and Visual FoxPro Database entries were identical, even to the version number, not surprising I suppose as I supply the ODBC drivers with my application (using the built in Microsoft Setup program within VFP 6) in case users do not already have them installed. I removed the drivers on my PC and replicated the error, reinstalled my app and the error cleared, however the same procudure on the customer PCs made no difference - it still crashed with the 'Word was unable to open the data source' error at the .opendatasource line below.

My automation code looks something like the following in my Visual FoxPro 6 program

with oword

&& copy cursor to a temporary file on disk for use by Word mailmerge
select * from customers into table mytable
&& close new file file so not open when Word tries to open it later
use
with oword.odocument.mailmerge
.MainDocumentType = wdFormLetters

.OpenDataSource(;
"mytable",;
,;
,;
,;
,;
,;
"",;
"",;
,;
"",;
"",;
"DSN=Visual FoxProTables;UID=; PWD=; SourceDB=c:\mydir"+;
"SourceType=DBF; Exclusive=No; BackgroundFetch=Yes; Collate=MACHINE"+; "Null=Yes; Deleted=Yes;",;
"SELECT * FROM mytable",;
"")
endwith

I suspect some incompatible default option in Word XP that sets itself differently when you upgrade from Word 2000 rather than earlier versions or for fresh installs, however, I am really stuck on this. Obviously I could export to different file formats and try that, however, that seems a shame when the code above has been working fine in all Word 2000 and most Word XP installations for a long time now.

Any help on this would be really appreciated. Thanks

Paul
 
I know you should only place in a single forum, however, due to the unusual nature of this problem I have placed it both here and in the VFP forum. At this stage it is unclear whether the solution lies in VFP automation coding for Word or whether it is simply a Word setup problem hence asking it here. I am reluctant to move it from here because a solution that worked last time I saw this problem was on a PC which upgraded straight from Word 97 to Word XP, that PC got the message I quoted 'unable to open data source' when VFP fired the 'opendatasource' automation command at Word. When, however, I installed Word 2000 on that PC then upgraded that to Word XP it worked absolutely fine as it does on all my other Word XP customer environments. This is the second time I have come across a PC going straight from Word 97 to Word XP and it shows the same problem. The customer does not have a copy of Word 2000 to try my solution and obviously it would breach copyright to send them mine to try. The evidence does therefore point to some Word XP setup issue but what I do not know. I have compared all tools, options settings at my end with the customer end and set them all to the same value. I have compared ODBC driver settings and versions and they are identical. The FoxPro code is identical and works in other Word XP environments including my own. I have had no feedback from the VFP forum to suggest what might be wrong other than an idea for a rewrite avoiding Words built in mailmerge facilities all together which would be a lot of work for a problem that crops up once in a blue moon.

Can I therefore ask if there are any more ideas in this forum that might help with this? Thanks

Paul
 
Hi
I just had the same happen on one of my apps. MailMerge works fine in Word 2000 with Access database (2k or XP), but with Word 2002 I get error: Word was unable to open the data source. I searched MS knowledge site and got this: Does anyone know if this has been fixed or has a solution?
Thanks
 
Did some more research, and it might as simple as changing the setting on your Word doc: Options-General- then enable (check) "Confirm conversion at open". Then in your code or using mail merge wizard, select DDE as your connection option. Worked for me.
Good luck!
 
Thanks for the ideas. Unfortunately my connection string is well under 255 characters and confirm conversion at open is ticked by default so not got me any further for now.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top