Help required with code - Automation Error ......... Ooops - Here's the code
Here is the code I omitted to send
Sub MailMergeTest()
Dim WD As Object
Set WD = CreateObject("Word.Application")
WD.Application.DisplayAlerts = wdAlertsNone
WD.Documents.Open (ThisWorkbook.Path & "\PrivList Labels.doc")
With ActiveDocument 'THIS LINE PRODUCES AUTOMATION ERROR IF RUN
TWICE
With .MailMerge
If .State < wdMainAndDataSource Then
.OpenDataSource _
Name:=ThisWorkbook.Path & "\PrivList.csv", _
LinkToSource:=True
End If
.Destination = wdSendToPrinter
.Execute
End With
.Close SaveChanges:=wdDoNotSaveChanges
End With
WD.Application.DisplayAlerts = wdAlertsAll
WD.Application.EnableEvents = True
WD.Quit SaveChanges:=wdDoNotSaveChanges
Set WD = Nothing
End Sub
|