Microsoft KB Archive/132095

{|
 * width="100%"|

PRJ4: Find Macro Method May Cause Run-Time Error 1004

 * }

Q132095

-

The information in this article applies to:


 * Microsoft Project for Windows, version 4.0
 * Microsoft Project for the Macintosh, version 4.0

-

SYMPTOMS
When you use the Find method in a macro, you may receive the one of the following error messages:

Run-time error '1004':

Could not find matching data.

"-or-"

Run-time error '1004':

Method Failed

This problem occurs if the Find method fails to find any matching data in a particular field.

CAUSE
The Find method should return False if it fails to find matching data. Instead, it causes one of the above run-time errors.

WORKAROUND
The following macro code demonstrates how to use error handling to bypass the run-time error 1004 when using the Find method.

Microsoft provides examples of Visual Basic procedures 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 Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

Sample Macro
Sub FindMethod

'The On Error Resume Next line specifies that when a run-time 'error occurs, control goes to the statement immediately following 'the statement where the error occurred. For examples on other 'ways of handling errors, see the On Error Statement Help topic. On Error Resume Next If Not Find("Name","contains",Value:="This is a test") then 'code if value not found Else 'code if value found End If End Sub

STATUS
Microsoft has confirmed this to be a problem in the products listed at the beginning of this article. We are researching this problem and will post more information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION
The run-time 1004 error message can have several different causes. For example, this message is displayed when the Find or FindNext command is called by a macro but there are no more tasks or resources to be found. This message can also mean that the argument value in the Find method could not be found; for example, if you are trying to find a specific task description in the project file but there are no tasks with that description.

Additional query words: warning execution

Keywords : kbcode kbprogramming kbofficeprog

Issue type :

Technology : kbHWMAC kbOSMAC kbProjectSearch kbProject400Mac kbProjectMacSearch kbProject400