Hi
Wonder if anyone can help, I find some help on youtube on how to get this working. It appears to work but I don't think it stops at the end of my data as in when i = "". Can anyone help??
The code is below
Any help would be very much appreciated
Thanks
Ant
Wonder if anyone can help, I find some help on youtube on how to get this working. It appears to work but I don't think it stops at the end of my data as in when i = "". Can anyone help??
The code is below
Code:
Sub LabelMerge()Dim oword As Word.Application, odoc As Word.Document
Dim sPath As String, i As Integer, oHeaders As Range
Set oHeaders = Range("a1").CurrentRegion.Rows(1)
sPath = ThisWorkbook.FullName
Set oword = CreateObject("Word.Application")
Set odoc = oword.Documents.Add
oword.Visible = True
odoc.Activate
odoc.MailMerge.MainDocumentType = wdMailingLabels
oword.Dialogs(wdDialogLabelOptions).Show
With odoc.MailMerge.Fields
For i = 1 To oHeaders.Columns.Count
.Add oword.Selection.Range, oHeaders.Cells(1, i)
oword.Selection.Font.Name = "ABC C39 SHORT"
oword.Selection.Font.Size = 28
oword.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
oword.Selection.TypeParagraph
Next i
End With
odoc.MailMerge.OpenDataSource sPath
oword.WordBasic.mailmergepropagatelabel
odoc.MailMerge.ViewMailMergeFieldCodes = False
odoc.ActiveWindow.View.ShowFieldCodes = False
odoc.MailMerge.Destination = wdSendToNewDocument
odoc.MailMerge.Execute
Set odoc = Nothing
Set oword = Nothing
End Sub
Any help would be very much appreciated
Thanks
Ant