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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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,224,760
Messages
6,180,816
Members
452,996
Latest member
nelsonsix66

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