Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Attaching datasource to Word XP
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00709221
Message ID:
00709783
Views:
17
Lee,

Silly question but have you created the ODBC connection on the other machine and is it using the same drivers, on my machine the "DSN=FoxPro Files - Word" is the wrong driver.

Just a thought.

>Caroline,
>
>The following code works when MS Word is either 97 or 2000.
>I copied the code out of my working Application and modified it to the basics.
>I then tested it against VFP 7 & Word 2000 to make sure it still worked.
>
>I have another computer connect to my network configured w/ VFP 7 & Word XP.
>I ran the same code against Word XP and when Word tries to open the dataSource it fails.
>
>Basically my statement is simular to yours.
>Thanks for your help.
>
>
>
>
>Clear
>On Error
>Set Exclusive off
>
>Close Databases all
>Create Database Addbs(Sys(2023))+"Test"
>Create Table Addbs(Sys(2023))+"MailMerge" (Field_1 C(15))
>Insert Into MailMerge (Field_1) Values ("2001-12345")
>Use In Select("MailMerge")
>
>oWord			= Getobject("","Word.Application" )
>lcWordVersion	= oWord.Version()
>MessageBox([Word Version ]+lcWordVersion)
>tcMailMergeFile	= Addbs(Sys(2023))+"MailMerge.dbf"
>tcMailMergeFile	= "C:\MailMerge.dbf"
>wdOpenFormatAuto = 0
>wdDoNotSaveChanges	= 0
>
>oDocument = oWord.Documents.Add(,,0)
>lcDocumentName	= oDocument.Name
>oWord.Visible = .T.
>
>** Office 97 & 2000
>**	Results from Word 2000 Macro Recorder
>*!*	    ActiveDocument.MailMerge.OpenDataSource Name:= _
>*!*	        "C:\MailMerge.DBF" _
>*!*	        , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
>*!*	        AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
>*!*	        WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
>*!*	        Format:=wdOpenFormatAuto, Connection:= _
>*!*	        "DSN=FoxPro Files - Word;UID=;PWD=;SourceDB=C:\;SourceType=DBF; _
>*!*	        Exclusive=No;BackgroundFetch=No;Collate=MACHINE;Null=Yes;Deleted=Yes;" _
>*!*	        , SQLStatement:="SELECT * FROM MailMerge.DBF", SQLStatement1:=""
>
>	lcRootPath			= JustPath(tcMailMergeFile) + ";"
>	lcDataFile			= JustFName(tcMailMergeFile)
>	lcName				= tcMailMergeFile
>	lnConfirmConversions	        = .F.
>	lnwdOpenFormatAuto		= .F.
>	lnReadOnly			= .F.
>	lnLinkToSource			= .T.
>	lnAddToRecentFiles		= .F.
>	lcPasswordDocument		= ""
>	lcPasswordTemplate		= ""
>	lnRevert			= .F.
>	lcWritePasswordDocument	        = ""
>	lcWritePasswordTemplate	        = ""
>	lcConnection			= "DSN=FoxPro Files - Word;UID=;PWD=;";
>				+ "SourceDB=" + lcRootPath ;
>				+ "SourceType=DBF;Exclusive=No;";
>				+ "BackgroundFetch=Yes;Collate=MACHINE;";
>				+ "Null=Yes;Deleted=Yes;"
>
>	lcSQLStatement			= "SELECT * FROM " + lcDataFile
>	lcSQLStatement1			= ""
>
>
>
>	lcOnError = ON("Error")
>	llDataSourceCreated = .T.
>	On Error llDataSourceCreated = .F.
>    oWord.ActiveDocument.MailMerge.OpenDataSource(;
>				lcName,;
>				lnwdOpenFormatAuto,;
>				lnConfirmConversions,;
>				lnReadOnly,;
>				lnLinkToSource,;
>				lnAddToRecentFiles,;
>				lcPasswordDocument,;
>				lcPasswordTemplate,;
>				lnRevert,;
>				lcWritePasswordDocument,;
>				lcWritePasswordTemplate,;
>				lcConnection,;
>				lcSQLStatement,;
>				lcSQLStatement1 )
>	On Error &lcOnError
>
>If llDataSourceCreated = .F.
>	MessageBox("MailMerge - OpenDataSource Failed")
>	oWord.Quit(wdDoNotSaveChanges)
>Else
>	oWord.Visible = .T.
>	Wait Window "OpenDataSource - Finished"
>EndIf
>
>
Caroline
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform