+ Reply to Thread
Results 1 to 5 of 5

VBA mailings selected receiver with combobox

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

    Question VBA mailings selected receiver with combobox

    Hi

    I'm working on a word document. I want to choose my receiver of the letter via a userform in excel (.xlsm-file) "Template[VBA]". The reciever could be chosen by a combobox "CB_Rec", there are 8 different selectable recievers: "Rec1", "Rec2", ....
    In the worksheet "Data_VBA" are the addresses of the recievers.

    Sheet: "Data_VBA"
    Column A: recievers
    Column B: First name
    Column C: Last name
    Column D: adress line
    Column E: postal code
    Column F: city
    Row 1 is the header of the columns

    Capture.PNG
    These cells (B2:F9) will automatically be filled by a database

    I've created a userform "UserForm1" with a combobox "CB_Rec" to choose the receiver. Then I want to press a commandbutton "CommandButton2" to generate an envelope (Word document "envelope[VBA]") with the address of the selected receiver.

    Now, I have to match the fields manually for mailings.
    Adress 1 : Street + No
    City: Postal code
    Postal code: City
    (city and postal code must me changed because of the Belgian letter layout)

    enveloppe.PNG

    After the envelope got generated, It has to be printed. Preferably also after I clicked "CommandButton2"
    And a messagebox will say "Uw enveloppe wordt gegenereerd" (your enveloppe will be generated)
    So, when I pushed the button, I'll get a printed envelope with the address of the selected reciever.

    Can someone help me?
    If you need more information, just ask.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA mailings selected receiver with combobox

    Welcome to the forum,
    Hi, for starters take a look here https://www.techwalla.com/articles/h...-data-in-excel
    Might help you, why invent the wheel if it's already there (somewhere)
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    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, Thanks for the fast answer. But I know how to made mailings from excel-lists. But I want to know how to automattically choose the right cells with the address when I chose the receiver with a combobox.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: VBA mailings selected receiver with combobox

    I would suggest an extra column where the value is set to True (or False) when selected and then loop thought the rows where the value is true to merge.
    I'll see if I can help you, probably not before tomorrow, undergoing a cataract operation this afternoon so won't be much behind my system ,)

  5. #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.
    Please Login or Register  to view this content.
    "Path word file"
    Please Login or Register  to view this content.
    Then you give an IF command for the selected receiver:

    Please Login or Register  to view this content.
    After that you place a recorded macro for the merging and the printing:

    Please Login or Register  to view this content.
    "Path for the selected excel list"
    Please Login or Register  to view this content.
    Path for excel list, (no double quotes)
    Please Login or Register  to view this content.
    `SheetName
    Please Login or Register  to view this content.

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

    I chose for receiver 1:
    Please Login or Register  to view this content.
    1
    For receiver 2 you choose:
    Please Login or Register  to view this content.
    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.

+ Reply to Thread

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