Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-04-2014, 04:01 PM
Mahmed1 Mahmed1 is offline Can't merge mail from Excel Windows 7 64bit Can't merge mail from Excel Office 2010 32bit
Novice
Can't merge mail from Excel
 
Join Date: Apr 2014
Posts: 17
Mahmed1 is on a distinguished road
Default Can't merge mail from Excel

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't merge mail from Excel mail merge in excel to send pdf forms heyullama Excel 7 12-01-2013 03:32 PM
Excel Mail merge Joren Word 0 07-09-2013 07:38 AM
Can't merge mail from Excel mail merge with excel and words don0712 Mail Merge 1 01-29-2013 06:53 PM
Can't merge mail from Excel Templates, pictures, Mail Merge and Excel kckay Word VBA 1 05-17-2012 08:51 PM
Can't merge mail from Excel Mail Merge from Excel Kieroncsmith Mail Merge 2 02-16-2012 10:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:21 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