+ Reply to Thread
Results 1 to 2 of 2

Macro to email as PDF only works when run for a second time.

  1. #1
    Registered User
    Join Date
    10-04-2014
    Location
    Surrey, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Macro to email as PDF only works when run for a second time.

    Hi

    I have pieced this macro together using bits from forums. The macro is to export a Rota, it sets the update date first, saves the workbook, then creates a folder for the year exports the sheet as a pdf, then its supposed to e-mail it to a list of recipients in a group in outlook... Excel on the second time of running the macro and overwriting the file opens Outlook and asks for permission to access, once granted the e-mail appears ready to send. Can anyone see why it has to be run twice? Also is there a way of sending the e-mail in the 'background'?

    Also from the macro that I copied to export to a pdf had the ActiveSheet.ExportAsFixedFormat... again after the End If, can I get rid of this bit?

    If anyone can see bits that I can 'clean up' that would be amazing' as i've very new to this level of Macros and don't yet fully understand what it is all doing...

    Cell AN78 contains the path to the newly created pdf as there are things on the sheet that make up the file name and this was the only way that I seemed able to get Attachements.Add to work when the filename is formed by the macro.

    Many thanks
    Chris

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    01-21-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    227

    Re: Macro to email as PDF only works when run for a second time.

    For this part of your question" Also is there a way of sending the e-mail in the 'background'?"-- just add .Send in the code after .Display

+ 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 Only Works Correctly One Time
    By s4driver in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-23-2013, 01:21 PM
  2. [SOLVED] Email Macro works once then gets stuck
    By cooket4 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2013, 09:54 AM
  3. [SOLVED] Macro with Problem to Sum Time, but If I use =value+value+value works..
    By feroguz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-30-2012, 04:39 PM
  4. macro works fine once than scrambles everything the second time
    By drocket in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2007, 04:49 PM
  5. Email Macro only sometime works?
    By PaulW in forum Excel General
    Replies: 0
    Last Post: 08-15-2006, 05:25 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