Send as PDF with original

When you install the Save as PDF and XPS addin for Office 2007, then you can also save your document in the pdf-format for several Office applications. Additionally it allows you to use the Send-> Email As PDF Attachment option to directly share send out the open document as a pdf-file.

On occassion it can be convenient to send out both the pdf out with the original. While previous versions of Office can also open the new Office file formats, this way you know for sure that they can at least open it (as pdf) if they cannot provide in-line comments (in the original document) when they haven't installed the compatibility addin.

This guide will explain how you can create that functionality with a macro in Word. It also has code examples for using this macro in PowerPoint and Excel.


Install the Save As PDF and XPS addin

You can download the Save As PDF and XPS addin for Office 2007 applications for free from the Microsoft website here. You need to install it for this macro to work.

Enable the Developer tab in Word

This time we will work from Word instead of Outlook and before we can create a macro in Word we have to enable the Developer tab on the Ribbon. To do this press the Office logo in the top left corner and click Word Options.

Word Options
Launching Word Options from the Office menu.

In Word Options select to enable the Developer tab on the Ribbon.

Enable Developer tab
Show Developer tab in Ribbon.

Create the Macro

As I already provide you with the code, creating the macro is easy. The code has been tested with Word and Outlook 2007 on Windows XP and on Windows Vista.

To launch the Visual Basic Editor select the Developer tab in the Ribbon and click Visual Basic Editor.

Developer tab
Launching the Visual Basic Editor from the Developer tab.

This will open a new screen. Select Normal in the left top pane and choose Insert-> Module to create a new module dedicated to this macro. Select the newly created module in the left pane and rename it to "MailPdfPlus" by changing the Properties value in the pane underneath. Copy and paste the code below to the module.


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

VB Editor
The code copied in the Visual Basic Editor.

Important!
Since this macro also uses Outlook functionality to create the mail, we must add the reference to the project. To do this choose Tools-> References… and select Microsoft Outlook <version> Object Library.
Here the word <version> stands for your version number of Outlook. Outlook 2007 for instance is version 12.0. An overview can be found here.
After enabling the reference, press OK.

Now we debug the code by choosing Debug-> Compile Normal. You shouldn't be getting errors if you've done everything correctly.
If you do get errors retrace your steps and also verify that any previous code you might have in Normal-> Microsoft Word Objects-> ThisDocument is correct. Debug until you've solved the errors (the code provided works correctly without any modifications).

To be able to run the code without setting your macro security level to medium I recommend that you sign your code which is a very easy process and only takes a minute. In this case make sure you sign the code in Word and not in Outlook.

Create a button for the macro

You can run the macro by selecting the Developer tab on the Ribbon and choose Macros. Select the MailPdfPlus macro and press Run. However the easiest way to access and use the macro is to create a button for it.

  1. Press the down arrow on the Quick Access Toolbar (QAT) and select More Commands…
  2. In the "Choose commands from" dropdown list choose Macros
  3. Select Normal.MailPdfPlus.Send_original_and_pdf and press the Add button
  4. Press Modify to change the Display name and icon
  5. Press OK to close the open dialogs.

Save Attachments
The “Send PDF with original” icon in the Toolbar.

Using the macro

To send the current document as an email press the icon. You'll get prompted to save the current document first if you haven't done that before. Otherwise it will do a background save. After this, it will open a new mail message with the current document attached and a pdf-version of it.

Other Office applications

Excel


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

PowerPoint


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