WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To work around this problem, use one of the following methods.
Method 1: Save as Word 6.0/95 from Word 98
Saving from Word 98 to Word 6.0/95 format retains the AddIn field and its
contents.
- In Word 98, click Save As on the File menu.
- From the Save File As Type list box select Word 6.0/95.
- Click Save.
Method 2: Word 7.0 and later - Custom Properties and the DocProperty field
You can create custom file properties that include any value you assign or
that are linked to specific items in your file, such as a named cell in
Microsoft Excel, a selected item in PowerPoint, or a bookmark in Word. For
example, in Microsoft Excel, you can create a custom file property to use
in all budget files that is linked to the cell that contains the budget
total. Then you can search for all budget files with totals that exceed a
certain value.
To create custom file properties for the active document, follow these
steps:
- On the File menu, click Properties, and then click the Custom tab.
- In the Name box, type a name for the custom property, or select a name
from the list.
- In the Type box, click the type of property you want.
- In the Value box, type a value for the property.
The value you enter must match the selection in the Type box. For
example, if you click Number in the Type box, you must type a number in
the Value box. Values that don't match the property type are stored as
text.
- Click Add.
After adding a custom property, to insert the custom property value into
your document, use the DocProperty field:
- On the Insert menu, click Field.
- In the Categories list box select Document Information.
- In the Field Names list box select DocProperty.
- Click Options.
- In the Property list box select the name of the custom property
containing the value you want to insert into your document.
- Click Add To Field.
- Click OK to return to the Field dialog box.
- Click OK to return to your document.
Method 3: Use document variables to store and retrieve values
In Word versions 6.0 and later you can use document variables to create and
later retrieve values stored within your document.
The following Visual Basic for Applications code sample adds a document
variable named "Customer Name" to the active document. The code then
retrieves and displays the value and then inserts the value stored in the
document variable at the current insertion point.
Sub AddDocVar()
Dim sVarName As String
Dim sVarValue As String
' Enter the variable name and value.
sVarName = "Customer Name"
sVarValue = "John Doe"
' If the named document variable already exists
' an error will occur, in which case, the value is updated.
On Error Resume Next
' Create the document variable and enter the document variable value.
ActiveDocument.Variables.Add Name:=sVarName
ActiveDocument.Variables(sVarName).Value = sVarValue
' Retrieve and display the value.
MsgBox ActiveDocument.Variables(sVarName)
' Retrieve and insert the value into the active document.
Selection.TypeText ActiveDocument.Variables(sVarName)
End Sub
To later retrieve these document variable values in Word versions 6.0 or
7.0 you will need to create a WordBasic macro. The following example shows
how to retrieve as well as set document variables using WordBasic.
NOTE: This macro will not run in Word 97 Visual Basic for Applications
without modification. For information about how to do this in Word 97, see
the Visual Basic for Applications macro example found earlier in this
article.
Sub MAIN
' Create the document variable and enter the document variable value.
sVarName$ = "Customer Name"
sVarValue$ = "John Doe"
SetDocumentVar sVarName$, sVarValue$
' Retrieve and display the value.
MsgBox GetDocumentVar$(sVarName)
' Retrieve and insert the value into the active document.
Insert GetDocumentVar$(sVarName)
End Sub