Microsoft KB Archive/268717

= Macro in Word 97 document that uses field name generates error in Word 2000 =

Article ID: 268717

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q268717



SYMPTOMS
In Word 2000, when you open a document that was created in Word 97 and run a macro that contains a field name, you receive the following error message:

Error! Bookmark not defined.



CAUSE
This problem occurs if both of the following are true:   The macro contains a statement that uses a field name; for example: Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _ Text:=&quot;FECHACREACION \@ &quot;&quot;dddd, dd' de 'MMMM' de 'aaaa&quot;&quot;&quot;, _ PreserveFormatting:=True -and-  The field name and options are not in English.

NOTE: This problem can occur for any field name that is not in English, not just the CREATEDATE field.



MORE INFORMATION
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.

Single Field Name Language Worldwide
The decision to use a single field name language worldwide was made to allow users of multiple languages to exchange documents more easily. Earlier versions of German, French, and Spanish Word required extensive language detection and field translation routines to allow users of one language version to open documents that were created in a different language version. This was effectively an attempt to localize a programming language where some parts of a string are tokens to be interpreted by the program, which should be translated, and other parts are user-viewable text, which should not be translated. This translation process made it difficult to add new features to the fields object model and could cause awkward results for multilingual users.

The new model of using nonlocalized field names is consistent with the model used for Visual Basic for Applications that has existed in Office since version 7.0/95, and for SQL, where the VBA statements, methods, properties, and so on, are in English regardless of the localized language. It allows a more seamless transition between languages, reduces possibilities of errors in translated documents, and gives the users of all international versions of the software a consistent experience.

Changing Word 97 Macros to Work in Word 2000 for Any Language
When you open a document that was created in a localized version of Word 97 (for example, French, German, or Spanish Word), Word 2000 changes the names of any fields and field options in the document from the local language to English. For example, if a document created in Spanish Word 97 has the field { FECHACREACION \@ &quot;dddd, dd' de 'MMMM' de 'aaaa&quot; \* COMFORMATO } in Spanish Word 2000, the field becomes { CREATEDATE \@ &quot;dddd, dd' de 'MMMM' de 'aaaa&quot; \* MERGEFORMAT }</B> A problem arises for a macro that uses a statement such as  Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _ Text:=&quot;FECHACREACION \@ &quot;&quot;dddd, dd' de 'MMMM' de 'aaaa&quot;&quot;&quot;, _ PreserveFormatting:=True because Spanish Word 2000 Visual Basic for Applications does not recognize FECHACREACION as a valid field name. For Spanish Word 2000, the statement should be  Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _ Text:=&quot;CREATEDATE \@ &quot;&quot;dddd, dd' de 'MMMM' de 'yyyy&quot;&quot;&quot;, _ PreserveFormatting:=True If you change the statement in the Spanish Word 97 macro to use English field names, the macro will no longer run in Spanish Word 97. In order for the macro to work in both Spanish Word 97 and Spanish Word 2000, make the following code changes: Dim sWordVersion as String

sWordVersion = Application. Version

If sWordVersion = (&quot;8.0&quot;) then

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _ Text:=&quot;FECHACREACION \@ &quot;&quot;dddd, dd' de 'MMMM' de 'aaaa&quot;&quot;&quot;, _ PreserveFormatting:= True

Else

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _ Text:=&quot;CREATEDATE \@ &quot;&quot;dddd, dd' de 'MMMM' de 'yyyy&quot;&quot;&quot;, _ PreserveFormatting:=True

End If

Additional query words: vba wd2000 word2000 macro fieldnames english french german spanish compatibility conversion

Keywords: kbfield kbmacroexample kbpending kbprb KB268717

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.