Could someone point me in the right direction on how to to a label mail merge using Word automation for address lables? Here is what I have so far. I am having issues with how to generate multiple labels on one sheet. Thanks.
Swi
Code:
Dim oApp As New Word.Application
Dim oMainDoc As Word.Document
Dim oSel As Word.Selection
Dim sDBPath As String
'Start a new main document for the mail merge.
Set oMainDoc = oApp.Documents.Add
With oMainDoc.MailMerge
.MainDocumentType = wdMailingLabels
sDBPath = App.Path & "\Address Book.mdb"
.OpenDataSource Name:=sDBPath, _
SQLStatement:="SELECT * FROM [Master]"
'Add the field codes to the document to create the form letter.
With .Fields
Set oSel = oApp.Selection
.Add oSel.Range, "Name"
oSel.TypeParagraph
.Add oSel.Range, "Address"
oSel.TypeParagraph
.Add oSel.Range, "City"
oSel.TypeText ", "
.Add oSel.Range, "State"
oSel.TypeText " "
.Add oSel.Range, "Zip"
End With
End With
'Perform the mail merge to a new document.
With oMainDoc
.MailMerge.Destination = wdSendToNewDocument
.MailMerge.Execute Pause:=True
End With
oMainDoc.Close
oApp.Quit
Set oMainDoc = Nothing
Set oApp = Nothing
Swi