Microsoft KB Archive/268435

= WD2001: Word 5.1 Mail Merge Document with Conditional IF Statement Converts Incorrectly =

Article ID: 268435

Article Last Modified on 1/27/2007

-

APPLIES TO


 * Microsoft Word 98 for Macintosh
 * Microsoft Word 2001 for Mac

-



This article was previously published under Q268435



SYMPTOMS
In Microsoft Word 2001, when you perform a mail merge using a document created in Microsoft Word 5.1, the mail merge operation may not function as expected. In the merged document, the information from the merged fields may be missing, and the document may contain an extra character (&quot;1&quot;).



CAUSE
This behavior occurs if the conditional IF statement in Word 5.1 does not correctly convert to Word 2001.



WORKAROUND
To work around this issue, create a macro that does the following:
 * 1) Turns on the field codes.
 * 2) Replaces every instance of space=space1space ( = 1 ) with a single space.
 * 3) Turns off the field codes.
 * 4) Selects the whole document.
 * 5) Updates the document so that the IF statements are updated.

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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

The following sample macro can be used to repair the conditional IF statements that have been imported from a Word 5.1 document: Sub fixfields ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes Application.DisplayStatusBar = True With ActiveWindow .DisplayHorizontalScrollBar = True .DisplayVerticalScrollBar = True .DisplayVerticalRuler = True .DisplayScreenTips = True With .View .ShowAnimation = True .ShowPicturePlaceHolders = False .ShowFieldCodes = True .ShowBookmarks = False .FieldShading = wdFieldShadingWhenSelected .ShowTabs = False .ShowSpaces = False .ShowParagraphs = False .ShowHyphens = False .ShowHiddenText = False .ShowAll = False .ShowDrawings = True .ShowObjectAnchors = False .ShowTextBoundaries = False .ShowHighlight = True End With End With Options.LiveWordCount = False Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = &quot; = 1 &quot; .Replacement.Text = &quot; &quot; .Forward = False .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes Application.DisplayStatusBar = True With ActiveWindow .DisplayHorizontalScrollBar = True .DisplayVerticalScrollBar = True .DisplayVerticalRuler = True .DisplayScreenTips = True With .View .ShowAnimation = True .ShowPicturePlaceHolders = False .ShowFieldCodes = False .ShowBookmarks = False .FieldShading = wdFieldShadingWhenSelected .ShowTabs = False .ShowSpaces = False .ShowParagraphs = False .ShowHyphens = False .ShowHiddenText = False .ShowAll = False .ShowDrawings = True .ShowObjectAnchors = False .ShowTextBoundaries = False .ShowHighlight = True End With End With Options.LiveWordCount = False Selection.WholeStory ActiveWindow.ActivePane.LargeScroll Down:=-1 Selection.Fields.Update End Sub



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
To create a macro that updates all fields in a document or template, follow these steps:  On the Tools menu, point to Macro, and then click Visual Basic Editor. In the Visual Basic Project window, expand the Project ( / ) folder. Double-click ThisDocument.  In the Code window, type the code for either of the following macros.

To run the macro when you open the document, type the following code: Sub AutoOpen For Each aStory In ActiveDocument.StoryRanges aStory.Fields.Update Next aStory End Sub

-or-

To run the macro when you create a new document, type the following code: Sub AutoNew For Each aStory In ActiveDocument.StoryRanges aStory.Fields.Update Next aStory End Sub  On the File menu, click Save / .</li> Close the Visual Basic Editor.</li></ol>

Each time you open or create a document, the macro runs and updates all fields in the document or template.