+ Reply to Thread
Results 1 to 9 of 9

Macro mailto with all currently visible sheets as each a separate pdf attachement in mail

  1. #1
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Macro mailto with all currently visible sheets as each a separate pdf attachement in mail

    Hello,

    With the help of members on this forum I got the code below that Works fine the way it is, but in the Workbook a user has the ability to add ducplicates of a specific sheet by a button and if a user has done this then offcourse these "Variable" sheets will not be included in the code herunder and added as seperate pdf attachements.

    Thus my thought was now to convert the code below to print the ThisWorkbook instead. I found out that when using Thisworkbook.PrintOut it automatically ONLY prints out the visible sheets at the moment. This way I can manipulate what to be printet by hiding sheets in the beginning of the macro and then make them visible again in the end of the macro after the PrintOut is done.

    Thought I would copy that same idea into the code below, which is now based on attaching 2 specific Worksheets.

    So my question is:

    How to convert this code to add the ThisWorkbook instead of just 2 specific sheets?

    In other Words, How do I add ALL currently VISIBLE sheets as pdf attachements (each visible sheet as a seperate pdf Attached in the mail)?


    Thanks in advance


    P.S. I tried to change the
    Please Login or Register  to view this content.
    and deleting the one for Sheet2 With
    Please Login or Register  to view this content.
    but that did not work. If I do that then NO attachements are added at all.




    This is the code:

    Please Login or Register  to view this content.
    Last edited by tnuis; 09-15-2013 at 10:13 AM.

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    Hi,
    try this
    Please Login or Register  to view this content.
    Thank you 6StringJazzer
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    Yes, that did the trick john55, thanks

    Only after I tested it a couple of times I noticed that this macro ALSO automatically saves all the pdf attachements in the mail in the folder where the excelprogram is.

    So lets say I have the Excel file on my desktop, I open it, do my stuff and then rund the Mailto macro. The mail is generated just like I want it to and when all is done there is a copy of all of the generated pdf´s from the mail on my desktop.

    Any way to disable this so that there are no ekstra copies made?

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    try this
    Please Login or Register  to view this content.
    Last edited by john55; 09-18-2013 at 03:29 AM.

  5. #5
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    Thanks john55

    I also struggle with another problem now. The users have to wait for about 4-5 minutes before the "For Each ws In Sheets....." to start.

    After Macro button is pressed the empty email instantly shows but then nothing happens until about 4 minutes has passed. Then all of the sudden a msgbox pops up showing a progressbar for the creation of each sheet beeing published as pdf.

    It takes WAAAy too long. The funny thing is that after its completed, if I then close the email and then run the code again it runs in less than 10 seconds. If I close the workbook and open again the first time i runs this code it always takes 4-5 minutes.

    IN other words, the first time the macro is run after workbook is opened, it runs in SLOOOOOW mode. Second time and all times after that it runs normally.

    Any suggestions on how to speed things up ?

    By the way, they all run Office 2010.
    Last edited by tnuis; 09-28-2013 at 06:08 AM.

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    hi,
    I have no idea why the macro takes so long to create all pdf files on yr side, I tried it with 4 sheets with colored tables and it took few seconds to attach them, close it and tried it again and I had the same result, few seconds.
    I am really sorry, maybe try another approach, another code....

  7. #7
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    Here is my workbook. I guess it is a lot easier to troubleshoot with the actual workbook?

    The button in question is the one called "Mail til kunde".


    Hope this helps...I have been stuck on this last bug for 2 weeks now....

    https://www.dropbox.com/s/eejk47d133...20Workbook.xls

    The file is just to big so here is a dropbox share link instead.

  8. #8
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    as I told you, it takes 4-5 seconds to attach the sheets as pdf, and I tested it 3 times, same result.
    maybe someone else can help you with an idea...
    I thought I could be of help!

    Cheers

  9. #9
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    Ok, thanks for fixing the original problem though. I will start a new thread regarding the bug. Again Thanks!

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Macro mailto with all currently visible sheets as each a separate pdf attachement in m

    anytime, you are wecome, thank you for the rep and feedback. I am sorry I can not help you regarding the bug.

+ 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] How to 'mailto' 2 specific sheets as 2 separate attachements, in .PDF fileformat?
    By tnuis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2013, 03:41 AM
  2. Auto-send mail with attachement using VBA in Excel does not work on some PCs
    By Dominozzz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2013, 01:52 PM
  3. Copy pasting the cell of a mail attachement in to another sheet
    By safi0102 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-12-2013, 02:29 PM
  4. Can you e-mail separate sheets in an Excel Workbook file?
    By FruityPebbles in forum Excel General
    Replies: 5
    Last Post: 04-01-2012, 03:05 AM
  5. Replies: 2
    Last Post: 05-18-2005, 11:06 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