Signing Personal Macros

Excel protects you from workbooks containing macro viruses that can harm your computer. It also prevents you from running your own macros. If you haven't changed the default security setting, whenever you open a workbook that contains a macro, Excel displays a message stating that it won't enable macros from unsigned workbooks, including workbooks you've created yourself.

click to expand

One way to avoid this warning message is to change Excel's security level to Medium or Low, but then you have to either reassure Excel that you don't need the security each time you open your own workbook or forgo the protection from macro viruses.

You can enable your own macros without a warning message by adding a digital signature to your VBA project. Before you can sign a project, you need to obtain a digital signature. You can obtain a digital signature in one of three ways: you can request one from your company if you work for a company that can issue digital signatures; you can obtain one from a certificate authority such as VeriSign or Thawte; or you can create a self-signature for your own macros.


For information about how to obtain a digital certificate from an official certificate authority, type digital signature into the Help box.

Create a Personal Digital Signature

Included with your Microsoft Office XP CD is a program you can use to create a personal signature. If you already have a digital signature from your company or a certifying agency, do not create a personal signature, but use the official one you already have.

  1. Run the Microsoft Office Setup program. On the Features To Install screen, expand the Office Shared Features folder. Click the arrow next to Digital Signature For VBA Projects, click Run From My Computer, and then click Update.

    click to expand

  2. In Windows Explorer, search the drive that contains Microsoft Office programs for the file selfcert, and run the program.

    click to expand

  3. In the Your Name box, type your name and click OK. Click OK to close the confirmation box.


    A self-signed certificate can be forged. If you have concerns that someone may attempt to forge your signature in order to inflict a virus on you, you should obtain a signature from an official certifying agency.

  4. If open, close the Search Results window.

You've now created a personal signature that you can use to sign your macro projects.

Add a Signature to Your Project

You add a signature to the VBA project part of your workbook. If a virus-or anything else-changes the VBA project, the signature becomes invalid. The signature applies only to the VBA project, not to the workbook data, so anyone can change the worksheets without invalidating the signature.

  1. With the Chapter01 workbook open, activate the Visual Basic Editor, and on the Tools menu, click Digital Signature.

  2. In the Digital Signature dialog box, click Choose.

    click to expand

  3. In the Select Certificate dialog box, select the certificate with your name and click OK.

  4. Click OK to close the dialog box. Switch to Excel, and save and close the workbook.

The project in the Chapter01 workbook is now signed. If you need to modify a macro, as long as you do it on the machine that contains your digital signature, VBA automatically reapplies the signature. But no one else can reapply your signature to the project.

Trust a Signature

Now that you have a workbook containing a signed project, you can tell Excel to trust workbooks that contain macros you have signed.

  1. Open the Chapter01 workbook.

    click to expand

    A message asks whether you want to enable macros, and also whether you want to trust macros from this source in the future.


    When you create your own digital signature, Excel can't be certain that the signature is authentic, so it displays a warning message. If you obtain your signature from a certifying agency, no caution message appears.

  2. Select the Always Trust Macros From This Source check box, and click the Enable Macros button.

  3. Close the Chapter01 workbook, and then reopen it. No warning message appears. Excel recognizes you as a trusted source for macros.

Security is important when you create any programs, including macros. Security is especially important when you share applications with others. If you create macros for others to use, you'll probably want to obtain a properly authenticated digital signature to protect your work.

Microsoft Excel 2002 Visual Basic for Applications Step by Step
FrameMaker 6: Beyond the Basics
ISBN: 735613591
EAN: 2147483647
Year: 2005
Pages: 122
Authors: Lisa Jahred

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net