J
John Beschler
I am posting this again because considerable time has lapsed since my
original post due to Hurrican Ivan etc.
I have two computers both running Windows 2000 and office XP. I have written
some code to attach a dbase file to the document as a mailmerge source. The
code works fine on one of the machines, yet fails consistently on the other.
At first I suspected an obselete version of MDAC, so I installed the latest
MDAC (2.8). No help.
Below is the relevant code:
***********************************************************
Sub AttachMergeDB(bCreateNewDocument As Boolean)
If bCreateNewDocument Then
Documents.Add
End If
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource _
Name:="C:\MERGE\MERGEOUT.DBF", _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Provider=MSDASQL.1;Persist Security Info=True;Extended
Properties=""DSN=dBASE
Files;DBQ=C:\MERGE;DefaultDir=C:\MERGE;DriverId=533;FIL=dBase
5.0;MaxBufferSize=2048;PageTimeout=5;"";Initial Catalog=C:\MERGE", _
SQLStatement:="SELECT * FROM `MERGEOUT`", SQLStatement1:="",
SubType:=wdMergeSubTypeOther
' Connection:= _
' "DSN=dBASE
Files;DBQ=C:\MERGE;DefaultDir=C:\MERGE\;DriverId=533;MaxBufferSize=512;PageTimeout=5;" _
' , SQLStatement:="SELECT * FROM MERGEOUT.DBF", SQLStatement1:=""
ActiveDocument.MailMerge.EditMainDocument
End Sub
************************************************************
When this code is executed on the machine that runs correctly, the dbase
file is successfully "connected" to the word document as evidenced by the
"InsertMergeField" button becoming enabled.
On the computer where the code fails to execute succesfully, I get a
dialogue box (Select Data Source) to locate the connection file. On this
dialogue there are two tabs: "File Data Source" and "Machine Data Source". It
does not appear to matter which tab I select or which option on either tab I
select, I always get the same error: Run-time error '5922'" Word was unable
to open the data source.
FWIW, I can not manually select dbase as source for mail merge manually
either. I get: Word was unable to open the data source.
I really need some help with this as the client is getting VERY antsy!
Thanks,
John
original post due to Hurrican Ivan etc.
I have two computers both running Windows 2000 and office XP. I have written
some code to attach a dbase file to the document as a mailmerge source. The
code works fine on one of the machines, yet fails consistently on the other.
At first I suspected an obselete version of MDAC, so I installed the latest
MDAC (2.8). No help.
Below is the relevant code:
***********************************************************
Sub AttachMergeDB(bCreateNewDocument As Boolean)
If bCreateNewDocument Then
Documents.Add
End If
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource _
Name:="C:\MERGE\MERGEOUT.DBF", _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Provider=MSDASQL.1;Persist Security Info=True;Extended
Properties=""DSN=dBASE
Files;DBQ=C:\MERGE;DefaultDir=C:\MERGE;DriverId=533;FIL=dBase
5.0;MaxBufferSize=2048;PageTimeout=5;"";Initial Catalog=C:\MERGE", _
SQLStatement:="SELECT * FROM `MERGEOUT`", SQLStatement1:="",
SubType:=wdMergeSubTypeOther
' Connection:= _
' "DSN=dBASE
Files;DBQ=C:\MERGE;DefaultDir=C:\MERGE\;DriverId=533;MaxBufferSize=512;PageTimeout=5;" _
' , SQLStatement:="SELECT * FROM MERGEOUT.DBF", SQLStatement1:=""
ActiveDocument.MailMerge.EditMainDocument
End Sub
************************************************************
When this code is executed on the machine that runs correctly, the dbase
file is successfully "connected" to the word document as evidenced by the
"InsertMergeField" button becoming enabled.
On the computer where the code fails to execute succesfully, I get a
dialogue box (Select Data Source) to locate the connection file. On this
dialogue there are two tabs: "File Data Source" and "Machine Data Source". It
does not appear to matter which tab I select or which option on either tab I
select, I always get the same error: Run-time error '5922'" Word was unable
to open the data source.
FWIW, I can not manually select dbase as source for mail merge manually
either. I get: Word was unable to open the data source.
I really need some help with this as the client is getting VERY antsy!
Thanks,
John