Signing your own macros with SelfCert.exe

SelfCert buttonWhen you create a macro and are running Outlook with the default security settings, you are not able to run the macro at all or you’ll always get prompted first, unless you either tamper with the default security settings or sign your own code with a digital certificate.

Since it is not very common to have your own digital certificate, you probably set your macro security to a lower level to be able to run your macro.

There is no need for that; You can sign your own macros with SelfCert.exe so macros can run without lowering your Outlook security settings.

The steps to achieve this are as follows:


Locating SelfCert.exe

Where? buttonSelfCert.exe is the application called “Digital Certificate for VBA Projects”.

You can open the application by double clicking SelfCert.exe in the following location;

  • Windows 32-bit
    C:\Program Files\Microsoft Office\Office <version number>
  • Windows 64-bit with Office 32-bit
    C:\Program Files (x86)\Microsoft Office\Office <version number>
  • Windows 64-bit with Office 64-bit
    C:\Program Files\Microsoft Office\Office <version number>
  • Office 365 32-bit (Subscription based or Click-to-Run version of Office 2016 / 2019)
    C:\Program Files (x86)\Microsoft Office\root\Office16
  • Office 365 64-bit (Subscription based or Click-to-Run version of Office 2016 / 2019)
    C:\Program Files\Microsoft Office\root\Office16

When you are still using Office 2007 or Office 2010, it is also available in the Start Menu under:

  • Microsoft Office-> Microsoft Office <version> Tools-> Digital Certificate for VBA Projects
  • By typing “vba” in the Search field.

Open SelfCert.exe or the "Digital Certificate for VBA Projects" application by typing "VBA" in the Start Menu.
SelfCert is available in the Start menu when using Office 2007 or Office 2010.

Using SelfCert.exe

How? buttonSimply run SelfCert.exe after locating it by one of the methods listed above. It will prompt you to name the certificate. Personally, I use my username because that is the most convenient to me but you can also give it the name of your company or whatever you want.

After pressing OK, you’ll get a “SelfCert Success” message.

Create Digital Certificate with SelfCert.exe
As explained in the dialog, a self signed certificate is for personal use only.

Signing your code

Visual Basic buttonBack in the VBA Editor (ALT+F11) where you created the macro choose;

  • Tools-> Digital Signature…

You’ll see that the current VBA project isn’t signed yet. Press the Choose… button and you’ll get a screen to select a certificate. Now you can choose the certificate you just created.

Choose the Digital Signature for your VBA project
Currently the project is unsigned.

Certificate selection dialog in Windows 10.
Certificate selection dialog in Windows 10.

Certificate selection dialog in Windows 7.
Certificate selection dialog in Windows 7.

Verify your macro security level

First, let’s verify if your macro security level is still set correctly. You’ll need to do this in the main Outlook window and not from the VBA Editor window.

  • Outlook 2007
    Tools-> Macro-> Security…-> option: Warnings for signed macros, all unsigned macros are disabled
  • Outlook 2010 / 2013 / 2016 / 2019 / Office 365
    File-> Options-> Trust Center-> Trust Center Settings…-> Macro Settings-> option: Notifications for digitally signed macros, all other macros disabled

Verify that your macro security level is set correctly.
Verify that your macro security level is set correctly.

Important!
Now that we’ve signed the code and verified that the security settings are set correctly, you must close Outlook. You’ll get prompted if you want save changes to your VBA project. Choose “Yes”. Once Outlook is fully closed start it again.

Running your signed macro for the first time

VBA Macro buttonAll preparations are now done and you can run the macro in one of the following ways;

Since it is the first time that you are using the certificate, you’ll be prompted what to do. Select that you’ll always trust the macros or documents from this publisher and you’re done! Now your own macros will run without any nasty security prompts and you can still enjoy Outlook with your security settings on high.

Microsoft Office Outlook Security Notice - Press the "Show Signature Details" link to see who signed the macro.
Press the “Show Signature Details” link to see that you are indeed the one who signed the macro. If you can’t trust yourself…