opcfkamgmailcom
IS-IT--Management
Dear all
Can anyone help to resolve my problem
The following code could not perform mailmerge (without any abnormal messsage) which invoke through excel VB. Following is part of my coding
Appreciate if you can help
curdirectory = d:\temp
fileName = curdirectory + "\1NewIpPwd_Env_ossd.doc"
filedatasource = curdirectory + "\auto.xls"
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
On Error Resume Next
With appWd
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Password="""";" & _
"User ID=Admin;" & _
"Data Source=" & filedatasource & ";" & _
"Mode=Read;" & _
"Extended Properties=""HDR=YES;IMEX=1;"";" & _
"Jet OLEDB:System database="""";" & _
"Jet OLEDB:Registry Path="""";" & _
"Jet OLEDB
atabase Passw"
Set wdDoc = appWd.Documents.Open(fileName)
wdDoc.Activate
wdDoc.MailMerge.OpenDataSource _
Name:=filedatasource, _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:=strConnection, _
SQLStatement:="SELECT * FROM `Working$`", _
SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
With wdDoc.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = 99999
End With
.Execute Pause:=False
End With
Can anyone help to resolve my problem
The following code could not perform mailmerge (without any abnormal messsage) which invoke through excel VB. Following is part of my coding
Appreciate if you can help
curdirectory = d:\temp
fileName = curdirectory + "\1NewIpPwd_Env_ossd.doc"
filedatasource = curdirectory + "\auto.xls"
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
On Error Resume Next
With appWd
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Password="""";" & _
"User ID=Admin;" & _
"Data Source=" & filedatasource & ";" & _
"Mode=Read;" & _
"Extended Properties=""HDR=YES;IMEX=1;"";" & _
"Jet OLEDB:System database="""";" & _
"Jet OLEDB:Registry Path="""";" & _
"Jet OLEDB
Set wdDoc = appWd.Documents.Open(fileName)
wdDoc.Activate
wdDoc.MailMerge.OpenDataSource _
Name:=filedatasource, _
ConfirmConversions:=False, _
ReadOnly:=False, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Revert:=False, _
Format:=wdOpenFormatAuto, _
Connection:=strConnection, _
SQLStatement:="SELECT * FROM `Working$`", _
SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess
With wdDoc.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = 99999
End With
.Execute Pause:=False
End With