2007/11/02

VBA Digital Signature

Digital Signature for VBA Project

Once you have your digital certificate installed, you can sign the VBA projects associated with Word, Excel, and PowerPoint documents, templates, and add-ins. For Outlook, you can sign the VBA project that is associated with the installation of Outlook on a particular computer. Any time code in a signed VBA project is modified in any way, its digital signature is removed. However, modifying the contents of the document other than the VBA code won't invalidate the signature on a VBA project contained within the document. This is because only the VBA project is signed, not the entire document.
If you want to prevent users of your solution from accidentally modifying your
VBA code and invalidating your signature, lock the VBA project before signing it. Locking your VBA project doesn't prevent another user from replacing the with another digital signature. This is allowed so that a system administrator or end user can replace a current signature with an approved signature or re-sign a document after a previous signature expires.
Similarly, if you produce an add-in that adds code to a document's VBA project, your code should determine if the project is digitally signed and notify the user of the consequences of modifying a signed VBA project before continuing.

VBA Digital Signature - How to sign VBA projects

You create digital signature for VBA (Visual Basic for Applications) project by using a digital certificate.
If you don't already have a digital certificate, you must obtain one.
You can obtain a digital certificate from a commercial certification authority, such as VeriSign, Inc., or from your internal security administrator or Information Technology (IT) professional. Or, you can create a digital signature yourself by using the Selfcert.exe tool.
Because a digital certificate you create yourself isn't issued by a formal certification authority, VBA projects signed by using such a certificate are referred to as self-signed projects. Depending on how Microsoft Office digital-signature features are being used in your organization, you might be prevented from using such a certificate, and other users might not be able to run self-signed macros for security reasons.

Steps for VBA Digital Signature

2. Open the file that contains the VBA project you want to sign.
3. On the Tools menu, point to Macro, and then click Visual Basic Editor.
4. In the Project Explorer, select the project you want to sign.
5. On the Tools menu, click Digital Signature.
6. If you haven't previously selected a digital certificate or want to use another one, click Choose, select the certificate, and then click OK twice.
7. To use the current certificate, click OK.