Convert Excel to PDF before sending out automatically by email

David77

Board Regular
Joined
Jun 24, 2020
Messages
109
Office Version
  1. 365
Platform
  1. Windows
Hello Everybody,

I am currently trying to create an Excel macro that converts my excel sheet into a PDF file and then sends it out by email. My current macro can do this, but it cannot convert it to a PDF file. I tried to merge my current VBA formula with the one here:
to convert my excel sheet into a PDF file before sending it out. However, this did not work (I couldn't get this formula to work singlehandedly either).

Can somebody please help me in improving my formula so it converts my file into a PDF before it sends it out by email?

My current VBA looks like this:

Sub Email_From_Excel_Basic()

Dim emailApplication As Object
Dim emailItem As Object

Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)

' Now we build the email.

emailItem.To = "mymail@gmail.com"

emailItem.Subject = "Subject line for the email."

emailItem.Body = "The message for the email."

' Send the Email
' Use this OR .Display, but not both together.
emailItem.Send

' Display the Email so the user can change it as desired before sending it
' Use this OR .Send, but not both together.
'emailItem.Display

Set emailItme = Nothing
Set emailApplication = Nothing

End Sub

Or by photo:

1593588118366.png


If any of you should require further information, more photos or anything else, please let me know and I will respond immediately!

Thank you so very much! :)

Best regards,
David
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
S
Hello Everybody,

I am currently trying to create an Excel macro that converts my excel sheet into a PDF file and then sends it out by email. My current macro can do this, but it cannot convert it to a PDF file. I tried to merge my current VBA formula with the one here:
to convert my excel sheet into a PDF file before sending it out. However, this did not work (I couldn't get this formula to work singlehandedly either).

Can somebody please help me in improving my formula so it converts my file into a PDF before it sends it out by email?

My current VBA looks like this:

Sub Email_From_Excel_Basic()

Dim emailApplication As Object
Dim emailItem As Object

Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)

' Now we build the email.

emailItem.To = "mymail@gmail.com"

emailItem.Subject = "Subject line for the email."

emailItem.Body = "The message for the email."

' Send the Email
' Use this OR .Display, but not both together.
emailItem.Send

' Display the Email so the user can change it as desired before sending it
' Use this OR .Send, but not both together.
'emailItem.Display

Set emailItme = Nothing
Set emailApplication = Nothing

End Sub

Or by photo:

View attachment 17343

If any of you should require further information, more photos or anything else, please let me know and I will respond immediately!

Thank you so very much! :)

Best regards,
David

Sorry i made a mistake:

This is the actual code:

1593601830467.png
 
Upvote 0

Forum statistics

Threads
1,223,931
Messages
6,175,465
Members
452,646
Latest member
tudou

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