Grouping a sequence of live email addresses from Excel

Posted on 2012-09-03
Last Modified: 2012-09-05
My VB6 application generates an Excel spreadsheet.
Column H contains live email addresses, starting at row 5.
Here is the code:

sCol = "H"
For iI = 1 To iMaxItems
   sRow = CStr(iI + 4)
   sRange = sCol & sRow
   .ActiveSheet.Hyperlinks.Add Anchor:=.Selection, _
      Address:="mailto:" & .Selection.Value
Next iI

Open in new window

This works all right, for each individual email address.
But the user would like to select a group of them from the spreadsheet for a bulk emailing. (Most likely, the entire column H from Row 4 to the last item.)

But when I click the top one, I go directly to the email utility, without having a chance to somehow select all of them.

Any suggestions??

The only thing I can think of would be for the VB6 application to toss out a text file containing one long string of concatenated email addresses. Then the user would have to copy and paste into the "To" line of his email utility.

It would be slicker to do this directly from the spreadsheet.

By the way, with this in mind, the email address entries actually have a <comma+space> appended: "xxx@yyy, "
Question by:NormaPosy
    LVL 10

    Accepted Solution

    Excel makes it difficult to select a cell that contains a hyperlink. (If you pay attention to the cursor, when it's a hand, the link will open and when it's a plus, the cell will be selected.)

    If the mailto hyperlink contains a semicolon then my email program will send to two recipients. For example: ";". There is probably some upper limit to the number of characters that can appear in the hyperlink.

    Just out of curiosity, if there are email addresses in cells H4:H10, what do you want to happen when the user clicks on cell H8 (send to all 7 addresses or just the one in H8)?
    LVL 10

    Expert Comment

    Based on some quick testing, it appears that the upper limit is 1026 characters following "mailto:"

    Author Comment

    I will have to sit down with the user, then get back to you.

    Database has over 200 records. One element of each record is a five-character "attribute" string. There are a variety of subsets filtered on those five attributes, from which an abbreviated spreadsheet is generated.

    I have to find out if the user, having done that, intends to bulk email to all the filter survivors.
    LVL 10

    Expert Comment

    If that's the case, you will need to read the addresses after the filter has been applied and then pass them to the email application.

    Author Comment

    I think I figured it out. In the spreadsheet: Click on the cell immediately above the column containing the email addresses. Shift-click on the cell immediately below. Copy, and paste to the "To" email message line.

    Point 1: This assumes the top and bottom cells clicked on are empty. Otherwise the copied To line will have to be edited.

    Point 2: This isn't using the cell contents as "live" email addresses.

    Point 3: But that's ok. Each individual cell is still "live".

    Point 4: I believe this will satisfy the user. He can "live click" to email to one specific address, or he can bulk mail to all of them.

    Point 5: If he wants to email to a subset of the filter survivors, he should tell me that, and I will provide a finer filter.

    I will have one more sit-down with him, then I anticipate that this question can be closed.

    Meanwhile - - Thank You for your help.
    LVL 10

    Expert Comment

    You're welcome. Glad you got it figured out. The most interesting part of responding to this question was figuring out the upper limit for the string following mailto.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
    This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now