The short answer
To digitally sign a VBA macro, open the VBA editor (Alt+F11), choose Tools, then Digital Signature, pick a code signing certificate whose private key Windows can reach, and save the file as .xlsm, .docm or .pptm. Add a TimeStampURL registry value first so the signature outlives the certificate. On another PC, the signature lets the macro run without a prompt once your certificate is in that PC's Trusted Publishers store. For files downloaded or emailed, that is also the only way a signature gets past Office's internet macro block, and it never does for Excel add-ins.
On this page
- What does signing a VBA macro prove?
- Which certificate do you need?
- How do you sign in the VBA editor?
- How do you timestamp the signature?
- Can you sign macros from the command line?
- What are V3 signatures?
- How do you make it run for other people?
- Does a signature get past the internet block?
- Common errors and fixes
- FAQ
What does signing a VBA macro prove?
Signing a VBA macro attaches a signature to the VBA project inside the Office file: the code, not the cells, text or slides. Microsoft describes what that buys you narrowly: the signature shows the project has not been tampered with since it was signed, but it does not prove who wrote the project, and someone else can replace your signature with theirs. What it does give the reader is a named, verifiable signer that Office can be told to trust.
Two behaviours follow from the signature covering the code. Any change to the code in a signed project removes the signature. If the certificate that signed it is on the computer where the edit happens, Office signs the project again when the file is saved; anywhere else, the edited project is unsigned. Microsoft recommends signing only once the project is tested and ready to distribute, and locking the project before you sign so nobody changes it by accident.
Signing the macro is not signing the document
A macro signature vouches for the code only. If you need a contract or report whose content can be shown to be unchanged, that is a document signing certificate, a different product for a different job. A file can carry both. Certum's version, which My-SSL sells as a document signing certificate for PDF and Office files, signs Office documents as well as PDFs.
Which certificate do you need to sign a macro?
To sign a VBA macro you need a certificate with the code signing purpose whose private key Windows can reach. Which one depends on who has to run the macro: a self-signed certificate is trusted only where you install it by hand, an internal CA covers your own domain, and macros distributed to other organizations are, in Microsoft's words, typically signed with a certificate from a commercial certificate authority.
| Who runs the macro | Certificate | What the reader's PC needs |
|---|---|---|
| Only you, or a few PCs you manage | Self-signed, made with Office's SelfCert.exe | Your certificate added by hand to Trusted Root Certification Authorities |
| PCs in your own domain | Code signing certificate from your internal CA | Your internal root and your certificate in Trusted Publishers |
| Customers, partners, anyone else | Code signing certificate from a publicly trusted CA | Your certificate in Trusted Publishers (by prompt, script or Group Policy) |
For the third row, My-SSL sells Certum code signing certificates for individual developers and organizations; the same certificate signs macros, EXEs and installers. Certum's checks and paperwork are listed in the required documents guide.
The key is not a file you can copy any more
Since June 1, 2023, the CA/Browser Forum's Code Signing Baseline Requirements make CAs ensure that the private key of a publicly trusted code signing certificate is generated, stored and used in a hardware crypto module: a token, a smart card, or a cloud signing service. Certum's cloud certificates keep the key on a virtual card in its SimplySign service, reached through SimplySign Desktop and the SimplySign mobile app. Certum's signing manual shows SignTool selecting that certificate by its thumbprint; it does not cover Office macros, and we have not tested SimplySign in the VBA editor. The SimplySign Desktop setup guide covers the documented part.
How do you sign a macro in the VBA editor?
You sign a VBA macro in the VBA editor of the Office app that holds it: open the editor, choose Tools, then Digital Signature, pick your code signing certificate and save the file in a macro-enabled format. Microsoft documents the same steps for Excel, PowerPoint, Publisher, Visio, Outlook and Word on Windows. Set up timestamping first (next section) so the signature is timestamped as you apply it.
1. Open the file. On the Developer tab, click Visual Basic
(or press Alt+F11).
No Developer tab? File > Options > Customize Ribbon > tick Developer.
2. In the Project Explorer, select the project to sign,
e.g. VBAProject (Report.xlsm).
3. Tools > Digital Signature.
4. Choose..., select your code signing certificate, OK.
5. OK to apply the signature.
6. Save in a macro-enabled format:
Excel .xlsm Word .docm PowerPoint .pptm
Saving as .xlsx / .docx / .pptx drops the VBA project
and its signature.If the list in step 4 is empty, it usually means Windows cannot find a code signing certificate with its private key installed, which Microsoft names as a requirement; see the troubleshooting section. Microsoft also notes that users of commercial certificates can run into blocks caused by the hash algorithm used for signing. A V1HashEnhanced DWORD under HKCU\SOFTWARE\Microsoft\VBA\Security selects it (1 SHA-1, 2 SHA-256, 3 SHA-384, 4 SHA-512); Microsoft says the setting is in the latest Current Channel builds.
How do you timestamp a VBA signature?
You timestamp a VBA signature by adding a TimeStampURL value to the registry; the VBA editor has no timestamp option of its own. Microsoft says a timestamped macro is still treated as signed after the certificate expires, as long as the certificate is not revoked. Without one, DigiCert notes, Office warns the reader once the signing certificate has expired.
Key: HKEY_CURRENT_USER\Software\Microsoft\VBA\Security
TimeStampURL REG_SZ <timestamp server URL> (required)
TimeStampRetryCount REG_DWORD e.g. 3 (optional)
TimeStampRetryDelay REG_DWORD delay in milliseconds (optional)
# From now on the editor timestamps every signature it applies.
# Files you signed earlier keep their untimestamped signature
# until you sign them again.The server you put in TimeStampURL matters. DigiCert's instructions for VBA say Microsoft's VBA tools do not support the RFC 3161 timestamp protocol, and give http://timestamp.digicert.com as the URL for this case. Certum's signing manual uses http://time.certum.pl with SignTool's /tr option, which is RFC 3161; we found no Certum statement that the same address answers the older request the VBA editor sends, so check that a freshly signed file actually carries a timestamp before relying on it. The timestamping explainer covers why a timestamp keeps old signatures valid.
Can you sign VBA macros from the command line?
Yes. Microsoft's Office Subject Interface Packages (SIPs) teach Windows' signing stack to read Office files, so SignTool can sign and verify VBA projects without opening Office. Version 16.0.19416.43425, published October 21, 2025, comes as x64 and x86 self-extracting packages, runs on Windows 10 and 11 and Windows Server 2016 to 2025, and does not need Office installed. It is the route for batch re-signing and for build machines.
1. Install the Microsoft Visual C++ runtime the readme names.
2. Run the OfficeSips package and extract it to a local folder.
3. As Administrator, register the SIPs you need:
regsvr32 msosip.dll (legacy formats: .xls, .doc, .ppt ...)
regsvr32 msosipx.dll (Open XML formats: .xlsm, .docm, .pptm ...)
4. Sign and verify:
signtool sign /f C:\Certificates\cert1.pfx /fd SHA256 C:\Files\Report.xlsm
signtool verify C:\Files\Report.xlsmThree details from Microsoft's material decide whether this works. Office files carry up to three VBA signatures (legacy, agile and a third, newer format), and SignTool writes one per run: on an unsigned project, run it three times to create all three, which the readme calls best practice. Microsoft's V3 guidance says to use the x86 SignTool from the Windows SDK when you run the package's Offsign.bat, and that SignTool does not support Access files. And because the triple signature is not Windows' native dual signing, SignTool options that walk native signatures, such as verify /all, do not apply to it.
| VBA editor | SignTool + Office SIPs | |
|---|---|---|
| Needs Office | Yes, the app that holds the file | No |
| Many files at once | One file at a time | Scriptable |
| Picks the certificate | From the Windows certificate dialog | On the command line: a .pfx file, or a certificate in the store by thumbprint |
| Timestamp | TimeStampURL registry value | Not covered in the sources we checked; test on a copy |
| Access files | Not in Microsoft's signing page | Not supported |
With a key in a cloud service, the command line is the documented end of the chain. Certum's manual signs with signtool sign /sha1 <thumbprint>once SimplySign Desktop is connected, and the SIPs are what let SignTool open an Office file. Certum does not document the two together for macros, and we have not run that combination, so test it on a copy of one file first.
What are V3 VBA signatures, and do old macros need re-signing?
V3 is the VBA signature format Microsoft added after CVE-2020-0760, a flaw that could let someone change a signed VBA project without breaking its signature. It is available in Microsoft 365 version 2102 (build 16.0.13801.20266) and later, volume-licensed Office 2019 version 1808 and later, and updated Office 2016 builds. Older signatures keep working by default, and Microsoft recommends re-signing existing macros with V3 as soon as possible.
- Find them: the Readiness Toolkit for Office add-ins and VBA lists signed files that need upgrading, e.g.
ReadinessReportCreator.exe -sigscan -p C:\Macros -r -output C:\output. - Re-sign them: open each file, Alt+F11, Tools, Digital Signature, choose the certificate and save; the new signatures replace the old ones. For many files, use SignTool with the Office SIPs as above.
- Then lock it down: the Group Policy setting Only trust VBA macros that use V3 signatures, under User Configuration\Policies\ Administrative Templates\Microsoft Office 2016\Security Settings\Trust Center, makes Office ignore earlier-format signatures.
This matters to you as a publisher even if you never touch Group Policy: once a customer's IT team turns that policy on, a macro you signed before V3 counts as unsigned on their machines. Microsoft says files with a V3 signature still open and run in earlier or non-updated Office versions.
How do you make a signed macro run for other people?
A signed macro runs without a prompt on another PC once your code signing certificate is in that PC's Trusted Publishers store. A user can add you from Office's security prompt, an admin can push the certificate with Group Policy or certutil, and the macro setting decides what happens to everything that is not signed by a trusted publisher.
| How the certificate gets there | Fits |
|---|---|
| The user trusts the publisher from Office's security prompt | A few users; once per publisher. A file with a Mark of the Web has to be unblocked first. |
certutil -addstore TrustedPublisher <certificate file> in a script | Organizations without Group Policy |
| Group Policy: Computer Configuration\Policies\Windows Settings\Security Settings\Public Key Policies, right-click Trusted Publishers, Import | Domains; Microsoft recommends deploying the certificate centrally |
For PCs that should run only trusted-publisher macros, Microsoft's guidance is to enable the VBA Macro Notification Settings policy with Disable all except digitally signed macros and tick Require macros to be signed by a trusted publisher; in Excel this also blocks Excel 4.0 macros. A further option, Block certificates from trusted publishers that are only installed in the current user certificate store, stops users without admin rights from adding publishers themselves.
Plan for renewal. What goes into Trusted Publishers is the certificate that signed the macro, so a renewed or reissued certificate is a new one that readers' PCs have to receive the same way before macros you sign with it run silently. Validity limits for code signing certificates are covered in the code signing certificate validity guide.
Trusting a publisher is not limited to one file
Microsoft warns that every macro validly signed with the same certificate is treated as coming from a trusted publisher and runs, and that Trusted Publishers is a Windows-wide store, so the trust reaches beyond Office. Trusting a certificate trusts everything signed with it, so readers should add only the certificate you sign with, not one shared with other publishers.
Does a signature get a macro past "Microsoft has blocked macros"?
A signature gets a downloaded or emailed macro past the internet block only when the signer's certificate is already in the reader's Trusted Publishers store. Microsoft's evaluation order for a file with a Mark of the Web checks Trusted Locations first, then signed macros from a trusted publisher, then policy, then files the user had already trusted before the change, and otherwise blocks. Excel add-in files are the exception: a signature does not help them.
Windows adds the Mark of the Web to files from the internet or the Restricted Zone, such as browser downloads and email attachments, on NTFS drives. Since Office started blocking macros in those files by default, the reader sees a Security Risk banner, "Microsoft has blocked macros from running because the source of the file is untrusted", with no Enable content button. The default arrived in Current Channel version 2206, rolling out from July 27, 2022, in the Enterprise channels between October 2022 and January 2023, in Publisher on February 14, 2023 and in Project on August 13, 2024; Microsoft's rollout tables list Microsoft 365 update channels. It applies only to Office on Windows, not Mac, mobile or the web.
The catch for publishers is timing. A reader who opens your file with a Mark of the Web cannot add you as a trusted publisher from that file: Microsoft says the mark has to be removed first (file Properties, tick Unblock, or PowerShell's Unblock-File). So if you send macro files by email or download, the useful setup is the one Microsoft recommends: the reader's IT deploys your public certificate to Trusted Publishers in advance. Without that, the reader unblocks the file or opens it from a Trusted Location, and your signature only helps from the second file on.
Common errors and fixes
Six symptoms come up when signing VBA macros: no certificate to choose, a signature lost on save, a Security Risk banner on a downloaded file, a signed macro that still prompts, an expired signature warning, and a customer whose policy ignores pre-V3 signatures. Match yours below.
The Digital Signature dialog shows no certificate
Microsoft's V3 guidance notes that the private key must be correctly installed to sign a VBA project. Check the Personal store in certmgr.msc: is the certificate there, is it a code signing certificate rather than an SSL one, does it show a private key, and is the token or cloud signing client connected?
The signature disappears after saving
A save as .xlsx, .docx or .pptx drops the VBA project and its signature. Save as .xlsm, .docm or .pptm. If it disappears in a macro-enabled format, most likely the code changed after signing on a machine without your certificate: sign again.
"Microsoft has blocked macros from running because the source of the file is untrusted"
The file has a Mark of the Web and your certificate is not in that PC's Trusted Publishers store (or the file is an Excel add-in). Unblock the file, open it from a Trusted Location, or have IT deploy your certificate to Trusted Publishers before the next file arrives.
The macro is signed but users still get a prompt
The signature is valid but you are not a trusted publisher on that PC yet. The user can trust you once from the prompt, or IT can add your certificate to Trusted Publishers. With a self-signed certificate, it also has to be in Trusted Root.
Readers see an expired-signature warning
The project was probably signed without a timestamp. Add the TimeStampURL registry value, sign again with a valid certificate and confirm the new signature carries a timestamp.
A customer says your signed macro shows as unsigned
If their IT enabled Only trust VBA macros that use V3 signatures, a file signed before V3 counts as unsigned. Re-sign it on a current Office build, or with SignTool and the Office SIPs, and send the new file.
Updated October 14, 2026: the internet-block section is corrected (a macro signed with a certificate that is already in the reader's Trusted Publishers store does run from a downloaded file, except Excel add-ins); the page no longer says a signature proves who wrote the code or that Certum's timestamp server accepts the VBA editor's request; and new sections cover V3 signatures and command-line signing with the Office SIPs.
Frequently Asked Questions
Quick answers to related questions.
Can I sign a VBA macro without buying a certificate?
For your own machine, yes. Office includes SelfCert.exe, usually in C:\Program Files (x86)\Microsoft Office\root\Office16 (or the same path under C:\Program Files), which creates a self-signed certificate. Microsoft says Office trusts a project signed that way only on a computer where the certificate has been added to Trusted Root Certification Authorities in the current user's store. That is fine for testing and for a few machines you manage, and Microsoft calls it not very good for distributing macros to other people.
Does signing a macro stop the 'Microsoft has blocked macros' warning?
Only on machines that already trust you. For a file with a Mark of the Web, Microsoft's evaluation order opens the macros when they are signed and the signer's certificate is already in that device's Trusted Publishers store. If it is not, the macros are blocked, and the user cannot add you as a trusted publisher from that file until the Mark of the Web is removed. Excel add-in files are the exception: Microsoft says a signature and a trusted publisher do not help an Excel add-in that carries a Mark of the Web.
Do I have to re-sign after editing the macro?
Microsoft says any change to the code in a signed project removes its signature. If the certificate that signed it is still on your computer, Office re-signs the project automatically when you save. On any other machine the edited project is unsigned until someone signs it again, so sign once the code is final.
Where is the timestamp option in the VBA editor?
There isn't one. Timestamping is switched on with a TimeStampURL string value under HKEY_CURRENT_USER\Software\Microsoft\VBA\Security; after that the editor timestamps every signature it applies. DigiCert's instructions say the VBA tools do not support the RFC 3161 protocol, so the URL has to be a server that answers the older request format.
Is signing a macro the same as signing the document?
No. A VBA signature covers the macro project. It does not cover the cells, text or slides, which can change without touching it. Signing the document itself, for example a contract, is done with a signature line or a document signing certificate. A file can carry both.
Which Office applications can I sign macros in?
Microsoft's signing instructions cover Excel, PowerPoint, Publisher, Visio, Outlook and Word on Windows, and the steps are the same in each: open the VBA editor, then Tools, then Digital Signature. For command-line signing, Microsoft's V3 guidance says SignTool does not support Access files.
The bottom line
Switch on timestamping, sign the finished project in the VBA editor or with SignTool and the Office SIPs, re-sign anything older than V3, and get your certificate into your readers' Trusted Publishers store before files reach them by email or download. If the macros leave machines you control, a publicly trusted Certum code signing certificate gives your readers' IT a named publisher to add to Trusted Publishers (again after each renewal), and it signs your EXEs and installers too.