Article ID: 815006 - Last Review: November 23, 2006 - Revision: 3.4

WD2002: VBA Find.Execute ReplaceAll Method Does Not Return the Original Selection

Hotfix download is availableHotfix Download Available
View and request hotfix downloads

On This Page

Expand all | Collapse all

SYMPTOMS

After you run a macro that performs a Replace function on a selection of text, the original text selection may not be returned. For example, if you select the "<Tab>The quick brown fox <Tab>jumps over the lazy dog." text and you run a Visual Basic for Applications (VBA) macro that is similar to the following example to remove the tabs from the text selection, the text is no longer selected when the macro finishes running:
Sub VBAReplaceTest()

   Selection.Find.Replacement.ClearFormatting
      
      With Selection.Find
         .Text = "^t"
         .Replacement.Text = ""
         .Forward = True
         .Wrap = wdFindAsk
      End With
    
    Selection.Find.Execute Replace:=wdReplaceAll

End Sub
This symptom occurs if there is a replacement or edit at the beginning of a selection.
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 Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104)

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice (http://support.microsoft.com/gp/advisoryservice)

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 (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms)

RESOLUTION

Service Pack Information

This problem is corrected in Office XP Service Pack 3.To resolve this problem, obtain the latest service pack for Microsoft Office XP. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
307841  (http://support.microsoft.com/kb/307841/ ) How to obtain the latest Office XP Service Pack

Hotfix Information

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, submit a request to Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support (http://support.microsoft.com/contactus/?ws=support)
Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language. The English version of this fix should have the following file attributes or later:
   Date          Time    Size        File name
   -------------------------------------------------------------------
   15-Feb-2003   00:23   5,691,408   Winword.msp     (Client Patch)
   15-Feb-2003   01:05   6,636,568   Winwordff.msp   (Full File Patch)
After the hotfix is installed, the English version of this fix will have the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date          Time    Version       Size         File name
   ------------------------------------------------------------
   14-Feb-2003   20:30   10.0.5011.0   10,603,080   Winword.exe
				
This fix is a post-Office XP Service Pack 2 (SP-2) fix. To install the fix, you must have Office XP SP-2 installed. For additional information about Office XP SP-2, click the following article number to see the article in the Microsoft Knowledge Base:
325671  (http://support.microsoft.com/kb/325671/EN-US/ ) OFFXP: Overview of the Office XP Service Pack 2
Additionally, you may have to install Windows Installer 2.0 to install this fix. For additional information about the Windows Installer requirement for post-Office XP SP-2 fixes, click the following article number to see the article in the Microsoft Knowledge Base:
330537  (http://support.microsoft.com/kb/330537/EN-US/ ) OFFXP: Office XP Updates and Patches Released After September 2002 May Require Windows Installer 2.0

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Office XP Service Pack 3.

APPLIES TO
  • Microsoft Word 2002
Keywords: 
kbautohotfix kbqfe kbhotfixserver kbenv kbprb kbbug kbfix kbofficexppresp3fix KB815006
 

Article Translations

 

Related Support Centers