Save e-mail messages as pdf-file

Since Office 2007, Word, Excel and PowerPoint files can be saved directly as pdf-files. Sadly, this option is not available in Outlook 2007 or Outlook 2010. There are of course alternatives such as installing a pdf-printer, using Adobe Acrobat or a 3rd party add-in such as SaveAsPDF by Sperry Software.

Another way is to use the VBA macro in this guide which uses Word’s capabilities to save documents in the pdf-format. With the code provided and easy to follow instructions, it offers a great alternative if you only occasionally need to save messages in the pdf-format or when you are in an environment where you cannot install software yourself.

ToolTip!
SaveAsPDF - Sperry SoftwareSaveAsPDF by Sperry Software is an add-in to quickly archive your emails into pdf-files. The available options go well beyond what the macro in this guide or any pdf-printer can do. For instance, it can save a message together with its attachments into a single pdf-file. It can also monitor specified folders and automatically save messages as pdf-files in the background for archiving purposes.
If you decide to order use BH93RF24 to get a discount.


Save As PDF macro

The Save As PDF macro uses Word’s capabilities to save documents as pdf-file. In short, it saves the selected message (or any other Outlook item) in the mht-format which is then opened in the background in Word where a Save As operation is initiated for the pdf-format.

By assigning a button to the macro, you can save a message as a pdf-file as easy as you would have saved it before.

Quick Install

Use the following instructions to configure the macro in Outlook;

  1. Download this code-file (saveaspdf.zip) or copy the code below.
  2. Open the VBA Editor (keyboard shortcut ALT+F11)
  3. Extract the zip-file and import the SaveAsPDF.bas file via File-> Import…
    If you copied the code, paste it into a new module.
  4. Add a reference to “Microsoft Word <version> Object Library”
    (where <version> is either “12.0” for Word 2007 or “14.0” for Word 2010)
    You can do this in the VBA editor via;
    Tools-> References…
  5. Add a button for easy access to the macro.
  6. Sign your code.

Categorize icon on QAT and in Ribbon
A button can be added to the main Outlook window or to any of the open item windows.

Note:
It could take some time before the Save As dialog is shown as the macro first needs to load Word in the background. This can take about 3-5 seconds for a modern computer and 5-10 seconds for older/slower computers.
If the message holds external images (such as newsletters), the processing time could increase even more as the images are being downloaded.

Troubleshooting

Below you’ll find a couple of common issues which you could run into when using this macro and how to resolve them.

Outlook becomes inaccessible and Save As dialog doesn’t show
A common issue is that the Save As dialog doesn’t take the foreground, especially on Windows 7, and as a result Outlook becomes “unresponsive”.

This isn’t an issue with the VBA macro itself but a bug in Windows 7. When this happens, minimizing your Outlook screen by selecting it on the Windows Task Bar (as the Outlook windows itself will be inaccessible) should reveal the Save As dialog. When you have multiple Outlook windows open, hold SHIFT while right clicking on the Outlook icon and choose “Minimize all windows”. Clicking on the Show Desktop icon or pressing the Windows Logo key + M on your keyboard will also minimize everything.

A reasonable effective workaround for this issue is to load the VBA Editor just once during the Outlook session. To do this, press ALT+F11 and then directly close it again. Now when you run the macro, the Save As dialog will pop-up in the front.

Compile error: User-defined type not defined
When you get this error, most likely the line Dim wrdApp As Word.Application is highlighted as well. In that case, you have not enabled “Microsoft Word <version> Object Library” as a reference as indicated (step 4 of the Quick Install guide).

A reference to the Microsoft Word Object Library is required for this macro to work.
A reference to the Microsoft Word Object Library is required for this macro to work.

Macro appears to do nothing
If the macro used to work and when you are sure the Save As dialog isn’t hidden in the background but the macro suddenly stopped working, it is likely that the WINWORD.EXE process crashed the last time you were working with the macro. To recover;

  1. Close any open Word document and also verify that the WINWORD.EXE process isn’t listed anymore on the Processes tab of Windows Task Manager (CTRL+SHIFT+ESC).
  2. Open the Temp folder by typing %TEMP% in the Search box of the Start Menu or in a Run command.
  3. Locate the file www_howto-outlook_com.mht right click on it and choose;
    Open with-> Microsoft Word.
  4. Read the crash notice and confirm to open it.
  5. Close Word.
  6. Run the macro again.

Macro code

The following code is contained in the zip-file referenced in the Quick Install. You can use the code below for review or manual installation.


Click in the area above and press CTR+A to select all. Press CTRL+C to copy the code.