Page 65 - Microsoft Office Excel 2003 Programming Inside Out
P. 65

Exploring Visual Basic for Applications

                             Digitally Signing Workbooks and Macros
                             After you have acquired a digital certificate, you can sign a workbook by clicking Tools,
                             Options, Security, Digital Signatures, Add, <certificate_name>, OK. After you click Add, the
                             Select Certificate dialog box (shown in Figure 3-6) appears with a list of unexpired certifi€
                             cates available on your computer. You can then click the name of the certificate with which
                             you want to sign your workbook (or click View Certificate if you want to view the details of
                             the certificate in case some of your certificates have similar names) and click OK to sign
                             your workbook.












                                                                                                             Chapter 3





                             Figure 3-11.  The Select Certificate dialog box lists the certificates available for digitally
                             signing a workbook.

                             The process for signing code in the Visual Basic Editor is similar to signing a workbook. To
                             sign the VBA code associated with a workbook, you click Tools, Macro, Visual Basic Editor.
                             In the Visual Basic Editor, click Tools, Digital Signature, Choose, select a <certificate_name>,
                             and click OK. Unlike the Select Certificate dialog box that appears when you sign a work-
                             book, the Select Certificate dialog box that appears when you sign your VBA code lets you use
                             a certificate that has expired. Listing expired certificates is an odd choice because, as you’ll see
                             in the next section, signing a macro with an expired certificate is equivalent to not signing it
                             at all.

                             Note  After the author of this chapter (Curt Frye) signed a macro using an expired certifi­
                             cate, a warning box appeared about two minutes later indicating there was a problem with
                             the digital certificate and that the signature would be discarded. It would be better not to
                             list expired certificates at all, but detecting the problem before the code could be sent out
                             is an acceptable workaround.


                             Using Digital Signatures with the High Macro Security Setting
                             The preceding discussion of digital signatures sets the stage for discussing the High macro
                             security level. When you have your macro security level set to High, Excel is extremely
                             cautious about allowing any macros to run. If Excel doesn’t recognize the source that signed


                                                                                                        39
                                                                                        Part 2:  Visual Basic for Applications
   60   61   62   63   64   65   66   67   68   69   70