+ Reply to Thread
Results 1 to 9 of 9

Show worksheet name on Email attachment

  1. #1
    Registered User
    Join Date
    03-03-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    53

    Show worksheet name on Email attachment

    Good morning

    I have successfully written a macro which allows me to email an individual worksheet from a workbook:

    Sub eMail()
    ActiveSheet.Copy
    Application.Dialogs(xlDialogSendMail).Show
    ActiveWorkbook.Close SaveChanges:=False
    End Sub


    But the attachment shows 'Book1.xls' rather than the actual worksheet name, is there a way to alter this?

    Thank you

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Show worksheet name on Email attachment

    This is happening because you are copying a Sheet from your workbook, effectively creating a new book. why don't you just delete the first line

    Please Login or Register  to view this content.
    Alternatively, you need to rename the new book to be something similar, but not the same as the main book


    Please Login or Register  to view this content.
    Last edited by Mallycat; 04-23-2012 at 04:37 AM.

  3. #3
    Registered User
    Join Date
    03-03-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Show worksheet name on Email attachment

    Thanks Mallycat, I have tried both your suggestions but maybe am doing something wrong??, I am a complete novice at this so you need to bear with me..., each worksheet I have is actually an invoice which will be sent to separate clients, there are approx 60 worksheets in the workbook so each time I highlight the worksheet I just want to be able to invoke the macro and for the attachment to reflect the name of the worksheet(i.e. client).
    I have tried deleting the first line'ActiveSheet.Copy' but am advised that there is a sytax error, please could you clarify what you mean?
    I have also tried the 2nd code and it just comes up with the name of the workbook file name?.
    In essence I really don''t know how to incorporate your suggestions, are you suggesting that there should be a macro for each worksheet with the worksheet name in it?

    Thanks for your patience

    birchetts

  4. #4
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Show worksheet name on Email attachment

    OK, sorry my mistake. I misread the detail.

    Try this

    Please Login or Register  to view this content.
    this will leave a copy of the saved workbook on your drive.
    Last edited by Mallycat; 04-23-2012 at 06:40 PM.

  5. #5
    Registered User
    Join Date
    03-03-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Show worksheet name on Email attachment

    This works great Mallycat thank you very much, can you just clarify what you mean when you say 'this will leave a copy of the saved workbook on your drive'?, is this in addition to the email copy and where would it be located?

  6. #6
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Show worksheet name on Email attachment

    Yes, it leaves a copy of the sheet in your folder. I didn't have time to sort this out this morning. You could try this. Please be careful and back up first. This is crashing my Excel, but I think the code is correct but there is something wrong with my PC. but I can't be sure.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-03-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Show worksheet name on Email attachment

    Sorry to seem dumb but where is this folder located as I can't see it?

  8. #8
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394

    Re: Show worksheet name on Email attachment

    Just open a book, and then save it (file save as). Where ever the book is saved, that is the folder

  9. #9
    Registered User
    Join Date
    03-03-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Show worksheet name on Email attachment

    Many thanks again Mallycat

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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