WD98: Addin Field Data Lost in Word 6.0/7.0 Conversion

ID: Q184158

The information in this article applies to:

SYMPTOMS

When you convert documents between Microsoft Word versions 6.0, 7.0, and Microsoft Word 98 Macintosh Edition, the contents of an Addin field may be lost when you open the document in Microsoft Word versions 6.0 or 7.0 using the Word 98 import converter.

NOTE: The Addin field may display as a "pimprivate" field. The WordBasic GetFieldData$() statement will not work on this field.

CAUSE

Addin fields are not converted in Word versions 6.0 and 7.0 when opening a Word 98 document with the Word 98 import converter.

-and-

The conversion process changes the contents of the Addin field from ANSI to Unicode.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/

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 it's contents.

1. In Word 98, click Save As on the File menu.

2. From the Save File As Type list box select Word 6.0/95.

3. 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:

1. On the File menu, click Properties, and then click the Custom tab.

2. In the Name box, type a name for the custom property, or select a name

   from the list.

3. In the Type box, click the type of property you want.

4. 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.

5. Click Add.

After adding a custom property, to insert the custom property value into your document, use the DocProperty field:

1. On the Insert menu, click Field.

2. In the Categories list box select Document Information.

3. In the Field Names list box select DocProperty.

4. Click Options.

5. In the Property list box select the name of the custom property

   containing the value you want to insert into your document.

6. Click Add To Field.

7. Click OK to return to the Field dialog box.

8. 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

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q181058
   TITLE     : OFF98: How to Run Sample Code from Knowledge Base Articles

REFERENCES

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for
               Applications

Additional query words: wordcon vb vba vbe
Keywords          : kbdtacode OffVBA kbmacroexample macword98 
Version           : MACINTOSH:98
Platform          : MACINTOSH
Hardware          : MAC
Issue type        : kbprb

Last Reviewed: April 6, 1999