Hi Friends , this is very first macro for Mail Merge here i am trying to learn the mail merge however getting an error
I have an excel workbook where the first sheet is a Data and there is a Data From A1 to C5
Sub AllEnvelopes()
Dim oTable As Range, r As Long, c As Long, sAddr As String
Dim oWord As Word.Application, oDoc As Word.Document
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
With ActiveCell.CurrentRegion
For r = 2 To .Rows.Count ' Using R=2 to Skip Row (Headers)"
For c = 2 To .Columns.Count
sAddr = sAddr & .Cells(r, c) & vbCr
Next c
sAddr = Left(sAddr, Len(sAddr) - 1)
oDoc.Envelope.PrintOut , sAddr, , , , , , "Size10"
DoEvents: sAddr = ""
Next r
End With
oWord.Quit False
End Sub
when i Run this , it gives me an Error Type Mismatch here ""oDoc.Envelope.PrintOut , sAddr, , , , , , "Size10"
please help
I have an excel workbook where the first sheet is a Data and there is a Data From A1 to C5
Sub AllEnvelopes()
Dim oTable As Range, r As Long, c As Long, sAddr As String
Dim oWord As Word.Application, oDoc As Word.Document
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
With ActiveCell.CurrentRegion
For r = 2 To .Rows.Count ' Using R=2 to Skip Row (Headers)"
For c = 2 To .Columns.Count
sAddr = sAddr & .Cells(r, c) & vbCr
Next c
sAddr = Left(sAddr, Len(sAddr) - 1)
oDoc.Envelope.PrintOut , sAddr, , , , , , "Size10"
DoEvents: sAddr = ""
Next r
End With
oWord.Quit False
End Sub
when i Run this , it gives me an Error Type Mismatch here ""oDoc.Envelope.PrintOut , sAddr, , , , , , "Size10"
please help