+ Reply to Thread
Results 1 to 3 of 3

Trying to create a .pdf and attach it to email, but get .xls file instead

  1. #1
    Registered User
    Join Date
    04-05-2013
    Location
    Gurnee, IL
    MS-Off Ver
    MS365 (PC) Version 2310
    Posts
    51

    Trying to create a .pdf and attach it to email, but get .xls file instead

    I'm trying to create a .pdf file from an Excel file and attach it to an email. I can create the .pdf, but the .xls file attaches to the email instead.

    Sub PDFMAIL()
    '
    ' PDFMAIL Macro
    ' Creates a .pdf file of the first tab of the worksheet and attaches it to an email
    '
    Dim CurrentInvoice As String


    CurrentInvoice = Worksheets("Invoice").Range("F8").Value
    myPDFFilename = "4923 Invoice " & CurrentInvoice & ".pdf"


    ActiveSheet.Unprotect

    myDir = "C:\Users\sbernard\My Documents\Invoices"
    If Dir(myDir & "\" & myPDFFilename) = "" Then
    '
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\sbernard\Documents\Invoices\" & myPDFFilename, Quality:= _
    xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
    OpenAfterPublish:=False
    Application.Dialogs(xlDialogSendMail).Show
    Else
    GoTo 100
    100
    End

    End If

    End Sub
    Last edited by sbrnard; 04-19-2013 at 01:27 PM.

  2. #2
    Registered User
    Join Date
    08-30-2005
    Posts
    67

    Re: Trying to create a .pdf and attach it to email, but get .xls file instead

    Hi sbrnard,

    If you are using Outlook to send emails you can try to alter your code by adding these lines:

    Please Login or Register  to view this content.
    Hope it helps.

  3. #3
    Registered User
    Join Date
    04-05-2013
    Location
    Gurnee, IL
    MS-Off Ver
    MS365 (PC) Version 2310
    Posts
    51

    Re: Trying to create a .pdf and attach it to email, but get .xls file instead

    That worked! Thanks!

+ 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