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

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
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,215,129
Messages
6,123,218
Members
449,091
Latest member
jeremy_bp001

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