<!--
  canonical-url: https://www.avonture.be/blog/outlook-vba-pdf
  published:     2024-07-10
  This is a static plain-Markdown mirror generated at build time.
  Visit the canonical URL above for the fully rendered page, with images and interactive components.
-->

# Microsoft Outlook - VBA - Save emails as PDF

> Learn how to implement a VBA macro in Microsoft Outlook to easily save selected emails as PDF files to your hard drive, complete with step-by-step installation and usage instructions.

---
![Microsoft Outlook - VBA - Save emails as PDF](/img/v2/outlook_vba.webp)

**TL;DR**

This article shares a VBA macro for the Outlook desktop client that saves one or more selected emails as PDF files, added to the Ribbon as a custom button via the VBA editor. When run, it prompts for a save folder, whether to delete the emails from Outlook after export, and whether to name each PDF manually or from the email subject.

You may also need to select several emails from Microsoft Outlook and save them as [PDF files](/blog/markitdown) on your hard drive.

In my case, it was when I was complementary self-employed. I had to keep track of the orders I received and the invoices I sent. Saving my orders as PDFs meant that I could keep them as archives, even if my mail server failed.

This post will explain to you how to create such a macro for Outlook.

## Result

Select one or more emails, click the button, and the macro walks you through three prompts:

![Five emails selected](./images/five_emails_selected.webp)

1. A confirmation to proceed with the selected emails.
2. A folder picker — where the PDFs should be saved.
3. Whether to remove the emails from Outlook afterward, and whether to name each PDF manually or reuse the email's subject line.

At the end, every selected email is saved on your hard disk as a PDF.

## Prerequisites

You should have Microsoft Office on your hard disk and you need to have Outlook and Word installed.

The macro will not work with Office online.

## Installation steps

**Installation steps**

1. Just start your Microsoft Outlook client (as software on your hard disk; not in your web browser),

2. Press <kbd>ALT</kbd>+<kbd>F11</kbd> to open the `Visual Basic Editor` (aka `VBE`) window,

3. Click on the `Insert` menu then `Module`,

4. Click on the link <a href="https://github.com/cavo789/vba_outlook_save_pdf/blob/master/module.bas"><https://github.com/cavo789/vba_outlook_save_pdf/blob/master/module.bas></a> to open my repository on GitHub and click on the `Copy raw file` button to copy the source code in the clipboard

5. Back to Outlook and press <kbd>CTRL</kbd>+<kbd>V</kbd> in the editor so you paste there the code,

6. Close the `Visual Basic Editor` and come back to Outlook,

7. Click anywhere on the Ribbon and select `Customize the Ribbon...`

8. In the new dialog, click on the `New Group` button

9. In the *Choose commands from*, select `Macros`, you should see the `SaveAsPDFFile` macro as illustrated below.

10. Drag and drop the macro to your new group.

11. Click on the `OK` button to close the dialog.

You should see [your new group](/blog/vba-excel-ribbon), in my case, I've created the new group in `Home` and at the first position left so I've this:

![The new group](./images/ribbon_macro.webp)

## The folder and naming dialogs

The confirmation, folder picker and naming prompts are described at the top of this article. The folder picker looks like this:

![Where emails should be saved?](./images/where_to_save.webp)
