+ Reply to Thread
Results 1 to 9 of 9

Macro to select Files to attach

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

    Macro to select Files to attach

    I have the following macro which generates and email from Excel.

    I need the code the code amended to that it allows the user to attach selected files in c:\my documents

    Your assistance in this regard is most appreciated



    Please Login or Register  to view this content.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,262

    Re: Macro to select Files to attach

    This will give you an idea...
    Please Login or Register  to view this content.
    Last edited by sintek; 04-12-2020 at 05:03 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

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

    Re: Macro to select Files to attach

    Hi Sintek

    Thanks for the help. I am able to select the workbooks I want to attach to outlook


    I have named B1 as SubjectText & B2 as Bodytext (see range name in Code Ztext = [bodytext] & Zsubject = [subjectText]


    I am battling to get the subject named Subject Text to show in the subject line and Bodytext to show the contents in the body off my email


    It would be appreciated if you could assist -have attached sample data

    Please Login or Register  to view this content.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,262

    Re: Macro to select Files to attach

    Quick question...Do you have a Email signature set up in outlook...

    I also see your variable declaration is not set...As suggested...Otherwise an error would have popped up...
    Are you doing it this way because you are going to be looping down the list for multiple emails...

    Please Login or Register  to view this content.
    Last edited by sintek; 04-12-2020 at 08:51 AM.

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

    Re: Macro to select Files to attach

    Hi Sintek

    Thanks for the reply

    The Variable declaration has been set -see attached screen print

    1) I do not have email signature set up in outlook
    2) I do not need to loop down the list for multiple emails-Once emails attached I just need the subject to be inserted from the named range "subjectText" and the body of the email to be inserted from the named range "Bodytext"


    It would be appreciated if you could assist with the above so that the Subject line in inserted as well as the body i.e contents of the email
    Attached Images Attached Images
    Last edited by Howardc1001; 04-12-2020 at 10:09 AM.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,262

    Re: Macro to select Files to attach

    post 4 does that...Why named ranges for subject and body??

    Why not just...
    Please Login or Register  to view this content.
    Last edited by sintek; 04-12-2020 at 10:13 AM.

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

    Re: Macro to select Files to attach

    Hi Sintek

    Code from # 4 is working, except the are no line spaces for the body-see below

    Hi Dave Attached please find Sales Report for March 2020. Regards Howard

    Please Login or Register  to view this content.


    I decided to use range names as I find it easier to amend the content on the sheet

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,262

    Re: Macro to select Files to attach

    Never seen that used before hence post 6 suggestion...

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

    Re: Macro to select Files to attach

    Thanks for your input, which is much appreciated


    Will use your suggestion in post # 6

+ 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] Macro to attach all files in a folder
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2019, 09:01 AM
  2. Macro to create emails, attach files, add recipient and add subject line
    By dw_22801 in forum Outlook Programming / VBA / Macros
    Replies: 8
    Last Post: 05-08-2017, 05:11 PM
  3. Attach files created by macro to an email
    By JesseSingh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-04-2016, 12:12 AM
  4. [SOLVED] Macro to Import Multiple TXT Files into workbook - User to select files/directory
    By saber007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-15-2013, 08:43 PM
  5. Excel Email Macro - HELP! - Need to be able to attach two different files
    By benwahchang in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-29-2013, 08:41 AM
  6. Application.GetOpenFilename, Attach files to Email, Move files, Delete Original.
    By D_Rennie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2009, 12:11 AM
  7. I want to attach word files or PDF files to an excel database
    By Dianne Munro in forum Excel General
    Replies: 1
    Last Post: 03-22-2006, 08:15 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