Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 12-05-2013, 09:52 AM
jtemp57 jtemp57 is offline Code for mail merge to reference saved excel file Windows Vista Code for mail merge to reference saved excel file Office 2007
Novice
Code for mail merge to reference saved excel file
 
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
 

Tags
mail merge, vbs



Similar Threads
Thread Thread Starter Forum Replies Last Post
Code for mail merge to reference saved excel file VB code: populate combobox from columns in Excel file billybeach Outlook 2 04-27-2013 04:38 AM
Mail Merge Code (Default Display) ochiha_ita Mail Merge 3 04-22-2013 04:04 AM
Code for mail merge to reference saved excel file Code to stop as "save as" if the mail merge has not been done tonywatsonmail Mail Merge 4 04-27-2012 01:57 AM
Mail Merge saved to single .pdf treetop Mail Merge 1 08-10-2011 03:28 PM
Mail merge Field Code Manipulation macjnr Mail Merge 0 09-10-2009 11:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:41 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft