Saving a outlook item as pdf

brkkrkmz112

New Member
Joined
Oct 24, 2016
Messages
43
Hi everyone,

Im trying to open a outlook item through hyperlinks and saveas pdf file in a specific location. So far, I written something but can not achieve something works. Any help would be appreciated.
I get an error ""automation error library not registered"".

VBA Code:
Sub burak()

Dim outapp As Object
Dim foldername As String
Dim Msg As outlook.MailItem

Set outapp = CreateObject("Outlook.Application")
foldername = Selection.Hyperlinks(1).Address

foldername = ThisWorkbook.Path + "\" + foldername

Set Msg = outapp.Session.OpenSharedItem(foldername)
Msg.Display

Msg.SaveAs "C:\Users\Administrator\Desktop\Mail1\REFPDF" & "\" & foldername & ".pdf", olMSG


     Msg.Close olDiscard
End Sub



Capture.PNG
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You can see .PDF isn't one of the SaveAs options if you manually save the .msg file so I doubt you have different options through VBA.


You could look into using a PDF printer but you'd also need to look at setting the pdf printer as the default printer or changing it to the default in VBA at runtime.
You could also look at saving as .html, which will open in Word and then you can export as .PDF through Word.
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,020
Members
452,542
Latest member
Bricklin

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