macro to email workbook as .pdf keeps sending as .xlsm

uncle_buck

New Member
Joined
Apr 19, 2013
Messages
3
Hello,

I've recorded the following macro:

Sub email_fred_fax()
'
' email_fred_fax Macro
' self explanitory
'


'
Sheets("FRED FAX").Select
Sheets("FRED FAX").Copy
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Documents and Settings\John\My Documents\fred fax.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\DOCUME~1\John\LOCALS~1\Temp\Book2.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
Application.Dialogs(xlDialogSendMail).Show
ActiveWindow.Close
End Sub

However, when I go and run it, it doesn't attach as a .pdf.


Any help would be appreciated. Thanks!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Possibly get rid of the first line of code. Try this (untested):
Code:
Sub email_fred_fax()

    With Sheets("FRED FAX")
        .Copy
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "C:\Documents and Settings\John\My Documents\fred fax.pdf", Quality:= _
            xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
        ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "C:\DOCUME~1\John\LOCALS~1\Temp\Book2.pdf", Quality:=xlQualityStandard, _
            IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:= _
            False
    End With
    Application.Dialogs(xlDialogSendMail).Show
    ActiveWindow.Close
End Sub

Odds are that the wrong thing is active and you are saving as .xlsm because it is your macro workbook that is active. Explicitly specifying workbook and worksheet should solve that.
 
Upvote 0
Thanks for the quick reply. The end result is the same, an .xlsm attachement. :( I'll let you know if I figure anything out.
 
Upvote 0
ended up putting it in the body of the email with "send mail to recipient" which is probably better for the recipients. Now if i can just get the "emailer" to make sure outlook is open.
 
Upvote 0

Forum statistics

Threads
1,215,529
Messages
6,125,345
Members
449,220
Latest member
Edwin_SVRZ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top