PRJ98: Run-time Error if ReplaceAll Argument Set to True (173818)
The information in this article applies to:
- Microsoft Project 98 for Windows
This article was previously published under Q173818 SYMPTOMS
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.
CAUSE
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.
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements.
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:
120802 Office: How to Add/Remove a Single Office Program or Component
STATUS
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.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbbug kbdtacode kbmacro kbpending KB173818 |
---|
|