hi, tried this one but no luck again. it gave no error but my computer does not have any activity.
With oMainDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:="", _
connection:="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=pami_db;Data Source=JLU", _
sqlstatement:="select * from TBLUSERINFO", SubType:=wdMergeSubTypeWord2000
With .Fields
Set oSel = oApp.Selection
.Add oSel.Range, "USERID"
oSel.TypeParagraph
.Add oSel.Range, "LASTNAME"
oSel.TypeParagraph
.Add oSel.Range, "FIRSTNAME"
oSel.TypeText ", "
.Add oSel.Range, "MI"
oSel.TypeParagraph
oSel.TypeParagraph
oSel.TypeText "Dear "
.Add oSel.Range, "FULLNAME"
oSel.TypeText ","
oSel.TypeParagraph
oSel.TypeParagraph
oSel.TypeText " This letter is to inform you..."
oSel.TypeParagraph
oSel.TypeParagraph
oSel.TypeText "Sincerely, [Your Name Here]"
End With
End With
With oMainDoc
.MailMerge.Destination = wdSendToNewDocument
.MailMerge.Execute Pause:=False
End With
|