Results 1 to 5 of 5

VBA mailings selected receiver with combobox

Threaded View

  1. #5
    Registered User
    Join Date
    07-18-2019
    Location
    Leopoldsburg, Belgium
    MS-Off Ver
    Office 2016
    Posts
    5

    Re: VBA mailings selected receiver with combobox

    Hi guys, I found the solution.

    You let excel open the word file.
    Set wordapp = CreateObject("word.Application")
           wordapp.documents.Open
    "Path word file"
       wordapp.Visible = False
    Then you give an IF command for the selected receiver:

       If CB_Rec.Value = "receiver 1" Then
    After that you place a recorded macro for the merging and the printing:

    ActiveDocument.Shapes.Range(Array("Text Box 2")).Select
        ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
        ActiveDocument.MailMerge.OpenDataSource Name:= _
    "Path for the selected excel list"
    , ConfirmConversions:=False, _
            ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
            PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
            WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
            Connection:= _
            "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=
    Path for excel list, (no double quotes)
    ;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLEDB:Database Lockin" _
            , SQLStatement:="SELECT * FROM
    `SheetName
    $`", SQLStatement1:="", SubType:= _
            wdMergeSubTypeAccess
        With ActiveDocument.MailMerge
            .Destination = wdSendToPrinter
            .SuppressBlankLines = True
            With .DataSource
                .FirstRecord = 1
                .LastRecord = 1
            End With
            .Execute Pause:=False
        End With
       End If

    You can choose the row for data you want to use:

    I chose for receiver 1:
    .Firstrecord =
    1
    For receiver 2 you choose:
    .Firstrecord =
    2

    !!! My excel file contains Headers !!!

    Hope I can help others with this solution for my problem.
    Last edited by MLG360Sepy; 07-25-2019 at 03:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Remove Items from Combobox if selected in Another Combobox
    By meabrams in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-26-2017, 07:10 AM
  2. [SOLVED] selected combobox will automatic update in the list to another combobox
    By aimjhun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2014, 07:22 AM
  3. Replies: 3
    Last Post: 04-02-2013, 06:02 PM
  4. I need a ComboBox to return another Combobox if a specific answer is selected
    By concatch in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2012, 03:43 AM
  5. Combobox: How to determine the location of the selected item if combobox has rowsource
    By ahsanzafar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2012, 03:24 PM
  6. CC mail receiver line in Macro
    By Benjamin2008 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-21-2010, 09:21 AM
  7. use selected value from one combobox to populate another combobox
    By rjudge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2006, 09:10 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1