View Single Post
 
Old 12-05-2013, 09:52 AM
jtemp57 jtemp57 is offline Windows Vista Office 2007
Novice
 
Join Date: Dec 2013
Posts: 6
jtemp57 is on a distinguished road
Default

I deleted the .Destination and it works.

Another issue is that it is asking me twice to choose my list from excel before moving on. What do I need to modify below in order for it to stop doing this?

I also have created a form with a button attached to the code below. How do I get the form to pop up with the Word Document so that I can run the code below?

Code:
Private Sub Print_LOTO_Tags_Click()
Dim sPath As String
'Kill off any previous datasource connections
Application.DisplayAlerts = wdAlertsNone
'Let the user select a datasource
With Application.Dialogs(wdDialogMailMergeOpenDataSource)
  If .Show = -1 Then
    sPath = .Name
  Else
    GoTo NoMerge
  End If
End With
If sPath = "" Then GoTo NoMerge
'Run the merge
With ActiveDocument
  With .MailMerge
    .MainDocumentType = wdFormLetters
    .OpenDataSource sPath
    .SuppressBlankLines = True
    With .DataSource
      .FirstRecord = wdDefaultFirstRecord
      .LastRecord = wdDefaultLastRecord
    End With
    .Execute Pause:=False
    'Disconnect from the datasource
    .MainDocumentType = wdNotAMergeDocument
  End With
  .Saved = True
End With
NoMerge:
Application.DisplayAlerts = wdAlertsAll
End Sub
Reply With Quote