ID: Q173818
The information in this article applies to:
In Microsoft Project 98, when you run a Microsoft Visual Basic for Applications sub procedure (or macro) that contains the Replace method with the ReplaceAll argument set to true, you will receive the following error message after the replacements are made:
Run-time error '1004':
Microsoft Project has finished searching the <FieldName> field.
<n> replacements were made.
where <FieldName> is the name of the field you searched and <n> is the
number of replacements made.
Even though you receive this error, the Replace method is carried out correctly.
This error occurs when you set the ReplaceAll argument to True. In contrast, if you set the ReplaceAll argument to the default value (False) or, if you do not use the ReplaceAll argument, you will not receive the error message. Note that if you do not set the ReplaceAll argument to True, only the first character or characters will be replaced when you run the macro.
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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/supportnet/refguide/default.asp
To work around this problem and suppress the run-time error, add the
following line of code before the Replace method:
On Error Resume Next
For example, the following macro replaces all the Name fields that contain
the value of T with value of P.
Sub Macro1()
On Error Resume Next
Replace Field:="Name", Test:="contains", Value:="T", _
Replacement:="P",ReplaceAll:=True
End Sub
For more information about the Replace method, click the Office Assistant,
type "Replace", click Search, and then click "Replace Method."
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard Toolbar. If Visual Basic help is not installed on your computer, please see the following article in the Microsoft Knowledge base:
ARTICLE-ID: Q120802
TITLE : Office: How to Add/Remove a Single Office Program or
Component
Microsoft has confirmed this to be a problem in the versions of Microsoft Project listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
Additional query words: vba
Keywords : kbmacro kbdta kbdtacode PROJVBA
Version : WINDOWS:98
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbpending
Last Reviewed: May 18, 1999