Signing your macros with SelfCert

Total Views : 147
Zoom In Zoom Out Read Later Print

Getting security error when using your macro code and unable to run it. You may get it working by lowering your security but is it good. We will show you how you can do this without any security issues.

When we create a macro and are running Outlook with the default security settings, you may receive an prompt or may not be able to run it at all unless you  lower the default security settings or sign your VB code with a digital certificate.

You may not have your own digital certificate then you may consider setting your macro security to a lower level and run you macro without any problem. But lowering security level , there is no need for that. You can sign your macros with you own digital certificates using selfcert, then you can run your macros without lowering your Outlook security settings.

How to Sign a Macro

Use following steps to sign you macros.
1. Explore to one of location according to you windows and your office version

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
C:\Program Files (x86)\Microsoft Office\root\Office16(19)

Office 365 64-bit
C:\Program Files\Microsoft Office\root\Office16(19)

2. Click on SELFCERT.exe and you will see a prompt like this.

3. Enter name for you certificate you want for it and click on OK button. You will get a success message.

Note: self signed certificate is for personal use only.

4. Open VBA Editor.
5. Go to Tools -> Digital Signature

6. You will see project is not sign because we are doing it for first time. Click on Choose... button and select the certificate you have created if previous steps and click OK.

7. Click OK. (If You see confirm Security prompt click on OK button)

Verify your macro security level

This can be only done from main Outlook window so for that close you VBA Editor. 

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

Check for option, it should be selected: Notifications for digitally signed macros, all other macros disabled

You need to close Outlook. You’ll get prompted if you want save changes to your VBA project. Choose Yes. Once Outlook is closed start it again.

Running your signed macro

Now you are done with code sign process and lets run you macro now. You can use one of the following three options.
1. Run it directly from the Visual Basic Editor (ALT+F11).
2. Run it from the Macros dialog (ALT+F8).
3. Run it via a button that you created for the macro.

Note:

For the first time you are running your self signed macros you will be prompted for a security notice as following image. Click on Trust all document from this publisher.

No you can run your macros without lowering your outlook security. you need to follow these steps for all of your macros and need to select certificate created by you or you can create new one if previous one get lost.

See More

Latest Photos