When 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
- Using SelfCert.exe
- Signing your code
- Verify your macro security level
- Running your signed macro for the first time
Locating SelfCert.exe
SelfCert.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.
SelfCert is available in the Start menu when using Office 2007 or Office 2010.
Using SelfCert.exe
Simply 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.
As explained in the dialog, a self signed certificate is for personal use only.
Signing your code
Back 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.
Currently the project is unsigned.
Certificate selection dialog in Windows 10.
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.
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
All preparations are now done and you can run the macro in one of the following ways;
- Run it directly from the Visual Basic Editor (keyboard shortcut ALT+F11).
- Run it from the Macros dialog (keyboard shortcut (ALT+F8).
- Run it via a button that you created for the macro.
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.
Press the “Show Signature Details” link to see that you are indeed the one who signed the macro. If you can’t trust yourself…