File format and send via outlook

Scrappy666

Board Regular
Joined
Jul 6, 2012
Messages
215
Hi Everyone,

I've came across a small problem whilst writing my latest bit of VBA..

I have the below code which select the file format when sending a document through Outlook, however i want to send this document as a PDF.

I've tried amending the file extension to .pdf to no avail...
It does send as a PDF but it won't open the document, the error message is saying it's in the wrong file format :confused:


Select Case Sourcewb.FileFormat
Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
Case 52:
If .HasVBProject Then
FileExtStr = ".xlsm": FileFormatNum = 52
Else
FileExtStr = ".xlsx": FileFormatNum = 51
End If
Case 56: FileExtStr = ".xls": FileFormatNum = 56
Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
End Select


If anyone knows how I can amend the above to save as a PDF it would be greatly appriciated!!
The original code came from Microsoft's website:

Using VBA in Excel to Send Workbooks and Ranges Through E-Mail with Outlook (Part 1 of 2)

The exact bit i've used is under the heading 'Mailing Single Sheets as Attachments'

Thanks in advance,
Dan
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Sorry i'm not overly technical with VB!

Would that replace everything above?
And the file isn't being exported and saved, it's being sent by email in a further bit of code below, would this still work?
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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