Please Note: This article is written for users of the following Microsoft Word versions: 2007 and 2010. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Checking for a Security Certificate.

Checking for a Security Certificate

by Allen Wyatt
(last updated January 13, 2014)

1

You can "digitally sign" your documents and templates with a security certificate. Technically, it is the VBA projects attached to documents and templates that can be signed. In your macros you may want to verify that the certificate is in place. Checking for the signature programmatically can make it easier to manage the overall security efforts of a company.

The property you can use for this purpose is VBASigned. Make sure to point to a file name and location on your system. You can use it as follows:

Documents.Open FileName:="D:\dotfiles\temp.dotx"
If Not ActiveDocument.VBASigned Then
    MsgBox "Warning! This document has not been digitally signed.", _
      vbCritical, "Digital Signature Warning"
End If

The VBASigned property will be either True or False, depending on whether the document (in this case a template) has been signed.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (9410) applies to Microsoft Word 2007 and 2010. You can find a version of this tip for the older menu interface of Word here: Checking for a Security Certificate.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing the Context (Shortcut) Menus

A shortcut menu is a great way to quickly access the commands you regularly use. If you want to modify how Context menus are ...

Discover More

Creating Scenario Summaries

If you've defined a variety of scenarios for your workbook, Excel can provide a handy way to compare the effects of those ...

Discover More

Creating a Sort Order

Excel is very flexible in how it can sort your data. You can even create your own custom sort order that is helpful when ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (ribbon)

Removing a Macro from a Shortcut Key

Associate a macro with a shortcut key, and at some time you may want to break that association. (Perhaps so the shortcut key ...

Discover More

Determining If a Number is Odd or Even

Need to know if a number in a macro is odd or even? It's easy to figure out with the simple calculation shown in this tip.

Discover More

Finding Long Lines

Word is very dynamic in how it "flows" text from one line to another and one page to another. In most cases we are willing to ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 0 + 7?

2013-08-09 07:46:23

Bryan

Correct me if I'm wrong, but a security certificate only matters if you have any VBA code. Otherwise, you don't care if it's signed or not, so you could be warning users without merit.

Unfortunately, checking for code is not that straightforward. I started playing around with the Document.VBProject object, but quickly discovered that you have to change your security settings to a bit looser than I like (you have to enable "Trust access to VBA Project model"), and according to Chip Pearson, "many virus scanners may automatically and without warning or confirmation delete modules that reference the VBProject object, causing a permanent and irretrievable loss of code". Yikes!

If you can get past those two things, it didn't take too long to figure out how to count the code objects (ActiveDocument.VBProject.VBComponents.Count) what type they were (ActiveProject.VBProject.VBCompenents(i).Type) or determine if they had lines of code (ActiveDocument.VBProject.VBComponents(i).CodeModule.CountOfLines). It's not documented at all in the help (and what is documented is in the ooooold document style (same as in my Access XP documentation)), but you've gotta love intellisense!


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.