+ Reply to Thread
Results 1 to 9 of 9

VBA code exporting to PDF but not attaching the file to the email.

  1. #1
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    VBA code exporting to PDF but not attaching the file to the email.

    Hi,

    i am almost there with my code i am trying to PDF a range in excel and attach to an email. I am converting ok and opening up the email but i am missing the attachment and i am now stuck. I would really appreciate if someone could advise me how to adapt the code so it attaches just the range i have specified


    Please Login or Register  to view this content.
    Appreciate your help with this.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA code exporting to PDF but not attaching the file to the email.

    If fn contains the path and filename to the PDF that was created try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: VBA code exporting to PDF but not attaching the file to the email.

    Hi Norie,

    Thanks for your reply and that makes sense,. I have just noticed it is not saving the file, it is correctly opening up the range as a PDF along. i have checked the file name which is fine, must be something else in the code?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA code exporting to PDF but not attaching the file to the email.

    When the PDF opens does it actually have a name?

    Where is the value for fn coming from anyway?

  5. #5
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: VBA code exporting to PDF but not attaching the file to the email.

    Hi Norie, when the pDF opens up the name is that of the file which is not what i want actually i want it to be the same as the email subject title.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA code exporting to PDF but not attaching the file to the email.

    You need to move this up above the code that's meant to create the PDF.
    Please Login or Register  to view this content.
    Another couple of things you'll need to do is move this up to,
    Please Login or Register  to view this content.
    and change the code that creates the PDF to this.
    Please Login or Register  to view this content.
    So after all those changes you should end up with this.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: VBA code exporting to PDF but not attaching the file to the email.

    Hi Norie


    That is it, works perfectly. i will digest your comments now so i undertsand.

    Thankyou so very much for looking at this and heping.

  8. #8
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: VBA code exporting to PDF but not attaching the file to the email.

    Hi

    Is it possible to add Range ("d6) to the fn?

    fn = "H:\XXX\XX\XX " & Format(Now(), "DD-MM-YYYY") & ".pdf"

    Sorry one more thing how can i specify the sheet name, just in case another file is open it cannot accidently email the wrong sheet?

  9. #9
    Forum Contributor
    Join Date
    07-02-2013
    Location
    abbots langley
    MS-Off Ver
    Excel 2010
    Posts
    316

    Re: VBA code exporting to PDF but not attaching the file to the email.

    Hi i have worked out the filename :-)

    Please Login or Register  to view this content.
    Thanks

+ 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. Email (outlook) recipients attaching specific file name.
    By monkeypants in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 05-13-2015, 07:18 PM
  2. Email (outlook) recipients attaching specific Excel file name.
    By monkeypants in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 05-13-2015, 07:14 PM
  3. Need VB Code to Extract email address from File name and email the file
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-30-2012, 11:18 AM
  4. Replies: 11
    Last Post: 07-10-2012, 10:35 AM
  5. Attaching One Worksheet of a File to Email
    By MLCall in forum Excel General
    Replies: 0
    Last Post: 01-17-2012, 12:51 PM
  6. Macro. compiling email, attaching 1x sheet + 1x powerpoint file.
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-28-2011, 02:24 PM
  7. Exporting to a .txt file - VBA Code
    By gavsta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-17-2005, 05:05 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