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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to involve MailMerge in Excel

Status
Not open for further replies.

opcfkamgmailcom

IS-IT--Management
Aug 11, 2007
1
HK
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:Database 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
 


Hi,

On what statement does it error?

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top