![]() |
#1
|
|||
|
|||
![]()
Hi,
What is wrong with code :-( Nothing is happening with this code All i am trying to do is from my excel worksheet (Active worksheet) Mail merge Sheet 1 /Letters/Address block/Finish merge and rather than send to new document, send to document i am opening. Is there any bits of code i can take out I also have a Named range called Address to mail merge if that helps but if not then the range is on sheet1 Here is my code Code:
Sub RunMerge() Dim strWorkbookName As String Dim wdapp As Word.Application Set wdapp = New Word.Application Dim wddoc As Word.Document Set wddoc = wdapp.Documents.Add strWorkbookName = ThisWorkbook.Path & "\" & ThisWorkbook.Name With wddoc.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource _ Name:=strWorkbookName, _ AddToRecentFiles:=False, _ Revert:=False, _ Format:=wdOpenFormatAuto, _ Connection:="Data Source=" & strWorkbookName & ";Mode=Read", _ SQLStatement:="SELECT * FROM 'Sheet1'" .Destination = wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord 'Add address block field and update End With End With wd.Visible = True End Sub Last edited by macropod; 04-04-2014 at 04:59 PM. Reason: Added code tags & formatting |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
heyullama | Excel | 7 | 12-01-2013 03:32 PM |
Excel Mail merge | Joren | Word | 0 | 07-09-2013 07:38 AM |
![]() |
don0712 | Mail Merge | 1 | 01-29-2013 06:53 PM |
![]() |
kckay | Word VBA | 1 | 05-17-2012 08:51 PM |
![]() |
Kieroncsmith | Mail Merge | 2 | 02-16-2012 10:35 PM |