How to Sign a Word VBA Macro With Self-Cert
🔍 WiseChecker

How to Sign a Word VBA Macro With Self-Cert

You have written a VBA macro in Word that you want to run without seeing the security warning every time. Word blocks unsigned macros by default unless the document is in a trusted location. Signing your macro with a self-certificate tells Word that you created the code and lets you enable it for your own use. This article explains how to create a self-signed certificate with the SelfCert tool and how to apply that signature to your VBA project.

Key Takeaways: Signing VBA Macros with SelfCert

  • SelfCert.exe in Office Tools folder: Creates a personal digital certificate that you can use to sign your own VBA projects.
  • Tools > Digital Signature in VBA editor: Opens the dialog to choose your certificate and apply the signature to the current project.
  • Trust Center > Macro Settings > Trust access to the VBA project object model: Must be enabled before you can sign a project programmatically or manually.

What SelfCert Does and Why You Need It

SelfCert is a free tool included with Microsoft Office. It generates a digital certificate on your local machine. This certificate is not issued by a trusted third-party authority like VeriSign or DigiCert. It is only valid on the computer where it was created. When you sign a macro with a self-certificate, the signature proves that the code came from you and has not been altered since signing.

Word checks the certificate when you open a document that contains macros. If the certificate is not trusted, Word shows a security warning. To trust your own self-signed certificate, you must add it to the Trusted Publishers store on your machine. After you do that, Word will run your signed macros without prompting.

SelfCert is ideal for individual developers who write macros for their own use or for deployment within a small team where all users can install the same self-signed certificate. For macros distributed to many users outside your organization, you need a certificate from a commercial Certificate Authority.

Prerequisites

Before you start, verify the following:

  • Microsoft Office is installed. SelfCert is part of the Office Tools group.
  • You have administrator rights on your Windows machine to install the certificate into the Trusted Publishers store.
  • The VBA project you want to sign is not password-protected. If it is, remove the password first.

Steps to Create a Self-Signed Certificate and Sign Your Macro

  1. Locate and run SelfCert.exe
    On Windows 11 or Windows 10, open File Explorer and navigate to the Office Tools folder. The default path is C:\Program Files (x86)\Microsoft Office\root\Office16 or C:\Program Files\Microsoft Office\root\Office16. Look for a file named SelfCert.exe. Double-click it to launch the Create Digital Certificate dialog.
  2. Name your certificate
    In the dialog box, type a descriptive name for your certificate, such as “My Macro Certificate 2025.” Click OK. The tool creates the certificate and stores it in your personal certificate store. A confirmation message appears.
  3. Open the VBA editor in Word
    In Word, press Alt+F11 to open the Visual Basic for Applications editor. In the Project Explorer pane, select the project that contains the macro you want to sign.
  4. Open the Digital Signature dialog
    In the VBA editor, click the Tools menu and then choose Digital Signature. The Digital Signature dialog opens showing the current signature status of the project.
  5. Choose your certificate
    Click the Choose button. In the Select Certificate dialog, find the certificate you created in step 2. Select it and click OK. The certificate name now appears in the Digital Signature dialog under “The VBA project is currently signed with.”
  6. Apply the signature
    Click OK in the Digital Signature dialog. Word signs the VBA project with your self-signed certificate. Save the document to preserve the signature.

Add the Certificate to Trusted Publishers

After signing, Word still does not trust the certificate by default. Complete these steps to make Word trust your self-signed certificate:

  1. Open the document that contains the signed macro
    Double-click the document. Word displays a security warning bar below the ribbon. Click the File tab and then click Info.
  2. Enable the macro and trust the publisher
    In the Info pane, click the Enable Content button. A drop-down menu appears. Select Advanced Options. In the Microsoft Office Security Options dialog, select the radio button “Trust all documents from this publisher.” Click OK.
  3. Verify the publisher is trusted
    Open Word again. Go to File > Options > Trust Center > Trust Center Settings > Trusted Publishers. You should see your self-signed certificate listed there.

If the Signature Does Not Apply or the Macro Still Shows a Warning

The Digital Signature dialog shows “No certificate available”

SelfCert.exe may not have run correctly, or the certificate was created in the wrong store. Run SelfCert.exe again and give the certificate a new name. If the problem persists, open the Certificate Manager by pressing Win+R, typing certmgr.msc, and pressing Enter. Look under Personal > Certificates. If your certificate is missing, run SelfCert.exe as administrator.

Word still blocks the macro after signing

The most common cause is that the self-signed certificate was not added to the Trusted Publishers store. Repeat the steps in the section “Add the Certificate to Trusted Publishers.” If you already did that, check the Trust Center settings. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Select “Disable all macros except digitally signed macros.” This setting allows only signed macros to run. If you choose “Enable all macros,” Word ignores the signature entirely.

The signature breaks after you edit the macro

Any modification to the VBA code invalidates the digital signature. After you edit a macro, you must sign the project again. Open the VBA editor, select the project, and repeat steps 4 through 6 in the main instruction list.

SelfCert.exe is not installed

Some Office editions, such as Office Home and Student, do not include SelfCert.exe. If you cannot find the file, you can install it from the Microsoft Download Center by searching for “SelfCert.exe download.” Alternatively, use the PowerShell command New-SelfSignedCertificate to generate a certificate, then import it into the Personal store using the Certificate Manager.

Self-Signed Certificate vs Commercial Code Signing Certificate

Item Self-Signed Certificate Commercial Code Signing Certificate
Cost Free Paid, typically $100–$500 per year
Trust scope Only on the computer where created and trusted Trusted by all Windows computers by default
Distribution Suitable for personal use or small trusted teams Required for public distribution to many users
Expiration Typically 1 to 10 years, set during creation 1 to 3 years, must be renewed
Revocation Cannot be revoked centrally Can be revoked by the Certificate Authority

You can now sign your own VBA macros using SelfCert and configure Word to trust your self-signed certificate. After signing, test the macro by closing and reopening the document and verifying that no security warning appears. For a more permanent solution in a corporate environment, request a code signing certificate from your IT department or purchase one from a trusted Certificate Authority. As an advanced step, consider using the SignTool command-line utility to sign macros programmatically during a build process.