WD2000: Find and Replace in a Word Table Displays ASCII Character 13 as a Hollow Box (274134)



The information in this article applies to:

  • Microsoft Word 2000

This article was previously published under Q274134

SYMPTOMS

When you call Find.Execute and use a replacement string that contains ASCII character 13 (or vbCr, or vbCrLF) to replace text in a Word table, ASCII character 13 (Chr(13)) displays as a hollow box rather than producing a new paragraph as you might expect.

NOTE: This problem does not occur with Word 97, which produces new paragraphs in a table when a Find.Execute replacement string contains ASCII character 13.

RESOLUTION

To work around this problem, use the two-character sequence ^p to produce a new paragraph in your replacement string instead of ASCII character 13.

STATUS

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

MORE INFORMATION

Steps to Reproduce

  1. Create a new document (Document1) in Word 2000.
  2. Add a table to the document.
  3. Add the word Hello to various cells in the table.
  4. On the Tools menu, choose Macro, and then select Macros. Type the macro name test, select Document1 (document) in the Macros in drop-down list, and then click Create.
  5. Add the following code to the new macro:
    Sub test()
        ActiveDocument.Tables(1).Range.Find.Execute _
                                 FindText:="Hello", _
                                 Forward:=True, _
                                 ReplaceWith:="Hi" & vbCr & "There", _
                                 Replace:=wdReplaceAll
    End Sub
    					
  6. Press the F5 key to run the macro.

    Results: A hollow square appears between the words "Hi" and "There." The expected results are that the words "Hi" and "There" are separated by a paragraph mark.

Workaround

To workaround this problem, replace vbCr in the previous code sample with ^p:
ActiveDocument.Tables(1).Range.Find.Execute _
                         FindText:="Hi", _
                         Forward:=True, _
                         ReplaceWith:="Hi^pThere", _
                         Replace:=wdReplaceAll
				
(c) Microsoft Corporation 2000, All Rights Reserved. Contributions by Chris Jensen, Microsoft Corporation.


Modification Type:MajorLast Reviewed:8/27/2002
Keywords:kbbug kbDSupport kbProgramming KB274134