+ Reply to Thread
Results 1 to 10 of 10

mail an excel range in mail body

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    mail an excel range in mail body

    So I have this code which should mail from a sheet range A1:M42.
    However the code still sends the active sheet in whole.

    Can anybody give me some pointers why?
    (the code says that if you only select 1 cell it will send whole sheet but I'm think I do select a range A1:M42)

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: mail an excel range in mail body

    .
    Try this macro:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: mail an excel range in mail body

    Thanks for this Logit.
    Works nicely.

    However does that mean my own code was not correct?
    Actually I would like to know whats wrong with it.
    Especially because it is working just not taking the range I want it to take.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: mail an excel range in mail body

    .
    If you DIM a few variables (see changes at top of macro), the macro works. However, it sends the entire sheet (all 1,048,000) rows. I might have miscalculated but I didn't think
    your intention was to send the ENTIRE sheet as an email .... only the data entered on the sheet.

    When you try this macro version, save the workbook first as an .xlsm (macro enabled workbook). Otherwise, you may lose the entire workbook when the email is sent.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: mail an excel range in mail body

    Quickly put this in a test book.
    But it actually does the same it already did.
    Made the range all 1's and 2'on the outside.

    Now after executing the macro it puts a selection around all the 1's but also mails the 2's and the button used to run the macro....
    Attached the workbook so you can see.
    Attached Files Attached Files

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: mail an excel range in mail body

    .
    My error.

    I had not tested your macro. Now that I have ... I understand it sends only the data on the sheet, not the entire sheet.
    The display just before sending led me to believe it was sending the entire worksheet.

    You are correct it also sends the command button plus it attaches an image file of the command button to the email, 511 kb in size.

    I should have fully tested it before commenting. Again, my apologies.

  7. #7
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: mail an excel range in mail body

    Yes but the button is outside of the range (A1:M42) en all the 2's in my attached workbook are also all out of the range.

    So I still think it takes the full sheet.
    But real question is why it does not take the range.
    I would think this part in the code would do the trick:
    Please Login or Register  to view this content.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: mail an excel range in mail body

    .
    I've looked around the Net and cannot locate anything (yet) that explains why MailEnvelope is designed to do, what it does.

    Perhaps someone else has an explanation.

  9. #9
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: mail an excel range in mail body

    Ok thanks Logit.
    Think I just will incorporate your solution.
    Just wanted a way to mail a selection from an excel sheet into the mail body.
    MailEnvelop was no necessity.

  10. #10
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: mail an excel range in mail body

    Ok, found it....

    So here is were the problem was :
    Please Login or Register  to view this content.
    It should be this :
    Please Login or Register  to view this content.
    So aparently you should break this into 2 parts. Make the selection and then define that as the sendrange.

+ 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. Macros for Mail Range/Selection in the body of the mail along with attachment
    By xenon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2015, 06:29 AM
  2. Mail Range/Selection in the body of the mail along with an attachment
    By johnny_canuck in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-27-2013, 05:52 AM
  3. Excel VBA outlook - Range in mail body
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-25-2013, 06:33 AM
  4. Send e-mail with image on body (.html) on e-mail manager <> outlook
    By mariotnc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2012, 09:28 PM
  5. Replies: 1
    Last Post: 07-22-2012, 09:26 AM
  6. Paste excel range into a mail item's body
    By Tim in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2006, 05:10 PM
  7. [SOLVED] Mailing an excel range in the body of an e-mail
    By Andy Tallent in forum Excel General
    Replies: 3
    Last Post: 07-20-2005, 11:05 AM

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