+ Reply to Thread
Results 1 to 12 of 12

Email range to attach

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Email range to attach

    I have written code to attach a range which I have named Journals on sheet "Data"


    The range name for "Journals is A20:D24


    When running the macro, the workbook close and the sheet for the range "Journals" is not attached

    It would be appreciated if someone could check my code and kindly amend it


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

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,318

    Re: Email range to attach

    Give this a try.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Email range to attach

    Thy such modification:

    Please Login or Register  to view this content.
    DoEvents are probably not needed. but they shall not harm.
    And probably at the end of the day you will replace .Display with .Send

    You may need after Paste add also pasting special the width of the columns.

    I think the problem source was re-using a code which was originaly developed for sending whole sheet as the attachment, to send only one named range.
    Best Regards,

    Kaper

  4. #4
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Email range to attach

    Thanks for the help guys

    Kaper, I amended your code

    Please Login or Register  to view this content.
    I wanted to paste the formulas if any as values

    However, I get a run time error "application defined or object defined error"


    Kindly check & amend

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Email range to attach

    I'm reading this with smartphone, so cannot test, but try:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Email range to attach

    Thanks for amending this

    I now get "Method save as of_object_workbook failed" and code below is highlighted


    Please Login or Register  to view this content.

    Kindly test & amend

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Email range to attach

    Try with slightly modified filename like:
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Email range to attach

    Thanks Kaper

    I would like you to kindly amend the code below

    Please Login or Register  to view this content.
    so that the file to be attached is the name in A42 on sheet "Data"

  9. #9
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Email range to attach

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Email range to attach

    Thanks Kaper Works perfectly

  11. #11
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Email range to attach

    Glad to hear that, and thanks for marking thread solved and for the reputation added

  12. #12
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Email range to attach

    Hi Kaper


    I have added code that allow the user to set the page break. I need it amended so that once the page breaks have been adjusted in page Preview the macro will continue

    Please Login or Register  to view this content.

    It would be appreciated if you would kindly amend the code
    Last edited by Howardc1001; 05-03-2020 at 08:42 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. Macro to create an email, attach current workbook and also paste a range from sheet
    By StormFusion in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2019, 08:32 AM
  2. [VBA] Save Range as picture, save to file, attach to email
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2018, 07:34 AM
  3. Macro to attach range to email in new sheet but not send?
    By Serafin54 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-22-2014, 01:07 PM
  4. attach different worksheet and email them tdifferent email address through macro/vba/addin
    By arunverma004 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-03-2014, 08:20 AM
  5. [SOLVED] Email Macro to attach a non active worksheet to outlook email
    By mickgibbons1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-21-2013, 08:38 PM
  6. SaveAs PDF and attach to email macro won't attach?!
    By Rerock in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2012, 05:28 PM
  7. copy range of cells to a new tab and attach in an email
    By dzuspann in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-23-2012, 04:14 PM

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