T
TFTAJLLYMXZP
I'm trying to "update" my Word 2003 data connection code to Word 2007,
but I cannot connect to my source file. I'd appreciate any hints on
what's wrong. My data source file is a macro-enabled workbook (.xlsm)
with a single worksheet named "Parcels". Within that sheet, there is
a range named "Database" that includes the header row (Row 6,
actually) and all the data rows below it.
The code breaks on the MailMerge.OpenDataSource statement and throws
up a "Confirm data source" dialog that displays the single entry of
"OLE DB Database Files".
Anyone else getting this problem?
Here is the code:
Public Sub DoPackageMerge(gstrPackageDataSource As String)
Dim mrgPkg As MailMerge
Dim rngHeaderFooter As Range
Dim strSQL As String
Dim strSaveAs As String
Dim j As Integer
Dim lngError As Long
Dim strMsg As String
On Error GoTo Package_Err
Set mrgPkg = ActiveDocument.MailMerge
mrgPkg.MainDocumentType = wdCatalog
With mrgPkg
.OpenDataSource _
Name:=gstrRoot & Application.PathSeparator &
gstrPackageDataSource, _
AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Provider=Microsoft.ACE.OLEDB.12.0;" & _
"User ID=Admin;" & _
"Data Source=" & gstrRoot & Application.PathSeparator
& gstrPackageDataSource & ";" & _
"Mode=Read;" & _
"Extended Properties=""HDR=YES;IMEX=1;"";" & _
"Jet OLEDB:System database="""";" & _
"Jet OLEDB:Registry Path="""";" & _
"Jet OLEDB:Engine Type=37;" & _
"Jet OLEDBatabase Locking Mode=0;" & _
"Jet O", _
SQLStatement:="SELECT * FROM `Parcels$Database`", _
SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
. . .
.. . .
End Sub
Thanks,
Terry
but I cannot connect to my source file. I'd appreciate any hints on
what's wrong. My data source file is a macro-enabled workbook (.xlsm)
with a single worksheet named "Parcels". Within that sheet, there is
a range named "Database" that includes the header row (Row 6,
actually) and all the data rows below it.
The code breaks on the MailMerge.OpenDataSource statement and throws
up a "Confirm data source" dialog that displays the single entry of
"OLE DB Database Files".
Anyone else getting this problem?
Here is the code:
Public Sub DoPackageMerge(gstrPackageDataSource As String)
Dim mrgPkg As MailMerge
Dim rngHeaderFooter As Range
Dim strSQL As String
Dim strSaveAs As String
Dim j As Integer
Dim lngError As Long
Dim strMsg As String
On Error GoTo Package_Err
Set mrgPkg = ActiveDocument.MailMerge
mrgPkg.MainDocumentType = wdCatalog
With mrgPkg
.OpenDataSource _
Name:=gstrRoot & Application.PathSeparator &
gstrPackageDataSource, _
AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:="Provider=Microsoft.ACE.OLEDB.12.0;" & _
"User ID=Admin;" & _
"Data Source=" & gstrRoot & Application.PathSeparator
& gstrPackageDataSource & ";" & _
"Mode=Read;" & _
"Extended Properties=""HDR=YES;IMEX=1;"";" & _
"Jet OLEDB:System database="""";" & _
"Jet OLEDB:Registry Path="""";" & _
"Jet OLEDB:Engine Type=37;" & _
"Jet OLEDBatabase Locking Mode=0;" & _
"Jet O", _
SQLStatement:="SELECT * FROM `Parcels$Database`", _
SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
. . .
.. . .
End Sub
Thanks,
Terry