Microsoft KB Archive/274134

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

Article ID: 274134

Article Last Modified on 8/27/2002

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



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.



Steps to Reproduce
 Create a new document (Document1) in Word 2000. Add a table to the document. Add the word Hello to various cells in the table. 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.  Add the following code to the new macro: Sub test ActiveDocument.Tables(1).Range.Find.Execute _ FindText:=&quot;Hello&quot;, _ Forward:=True, _ ReplaceWith:=&quot;Hi&quot; & vbCr & &quot;There&quot;, _ Replace:=wdReplaceAll End Sub  Press the F5 key to run the macro.

Results: A hollow square appears between the words &quot;Hi&quot; and &quot;There.&quot; The expected results are that the words &quot;Hi&quot; and &quot;There&quot; are separated by a paragraph mark.</li></ol>

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

Additional query words: blackbox black automation automate execute method find object carriage return chr(13) new line

Keywords: kbbug kbnofix kbprogramming KB274134

-

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

© Microsoft Corporation. All rights reserved.