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

Last reviewed: September 26, 1997
Article ID: 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: 4.00 warning execution
Keywords : kbcode kbprg
Version : 4.0
Platform : WINDOWS
Issue type : kberrmsg


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 26, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.