MS Office Document Variable Metadata
Microsoft Acknowledges Document Variables “May” contain Metadata In Knowledge Base article 825576, Microsoft lists many potential metadata risk elements, and among those elements are document variables. The article doesn’t explain document variables, but explains how to view and then delete them. What are Document Variables? A document variable is stored as part of a document or template. Document variables store information about the document and can only be accessed using Visual Basic or viewed using a metadata viewer. VBA Code to Create and Display a Document Variable Sub SetDocVars() Dim sAuthorName As String Dim oThisVar As Variable 'For Each oThisVar In ActiveDocument.Variables If oThisVar.Name = "AuthorName" Then oThisVar.Delete Exit For End If Next oThisVar sAuthorName = ActiveDocument.BuiltInDocumentProperties(wdPropertyAuthor) ActiveDocument.Variables.Add Name:="AuthorName", Value:=sAuthorName MsgBox "AuthorName = " & ActiveDocument.Variables("AuthorName").Value End Sub Example of Hidden Document Variables using iScrub’s metadata viewer The the screen shots below show metadata from the same document. Notice that in Figure 1 the CREATATION DATE is 11/26/2003 and in Figure 2 the DOCX97 document variable has a date value of 10/12/99. This document continues to be used to create new documents t along with the hidden document variables. 
Figure 1 
Figure 2 Figure 2 shows document variables that are in the document TC-Design Agreement.doc. Uses of Document Variables - Hidden Stored values for macro automation
- Using the {DocVariable “DocVarName”} field code The DocVariable field code references the stored value of a document variable. Place this field code anywhere in the document and it will display the contents of a stored hidden document variable.
Document Variables are useful for document automation because they allow the programmer to store information for future use. For example, some firms use document variables to store Client and Author information for use in the footer or field code purposes. Unfortunately, many of these same macros aren’t self-managing, in that they leave this information in the document when it is no longer needed or related to the new document. It then becomes a metadata risk when it leaves the firm. How iScrub Manages Document Variables Metadata iScrub can, depending on the firm’s metadata removal and management setting of “ScrubDocVars” in the DetergentNet.xml, remove all document variables. To prevent errors in the document, iScrub will also search for {DocVariable} field codes and unlink the field code before scrubbing document variables Rules for Document Variable Best Practice - Know your document variables. If any automation is placing document variables in your documents, know why and what they are.
- Know what document variables already exist in your internal organic documents (those documents living and created in the firm). If you have had any outside company convert your documents, you should be aware of possible document variables used during the document conversion.
- Use a metadata removal utility and metadata viewer such as iScrub or iDiscover (free download) to identify document variables in your documents. This tool must be available to all of your users.
- Think through the use of the document variable and try to use a non-hidden metadata method to accomplish the same thing.
Conclusion Document Variables are an effective and useful reference variable store for Microsoft Word macro automation. Firms should be aware of document variables and the associated metadata risk. Firms should reassess any use of document variables to determine if there is a different non-hidden approach to accomplish the same thing. (reprinted by permission from Esquire Innovations)
Return to White Papers main page from Document Variable Metadata
|