Err Msg: "Command Could Not Be Completed..." Opening File |
Q113269
In Project, when you use the FileOpen method in a macro to open a file, you receive the following error message if the file is already open:
Run-time error '1004':
Command could not be completed successfully
To avoid receiving this error message when you use the FileOpen method to open a project file, you can use the following method as an example:
Sub Open_File()
Dim i As Integer
Dim Filename As String
Dim filefound As Boolean
' Filename string must be in all capitals
' Replace following line with desired path and filename
Filename = "C:\WINPROJ\TEST.MPP"
' Check window name of each open project
For i = 1 To Windows.Count
' Check window name against Filename
If InStr(Filename, Windows(i).Caption) <> 0 Then
' If project is already open, activate the window
Windows(i).Activate
Filefound = True
End If
Next I
' If the project was not found as an open window, open the project
If Not Filefound Then FileOpen Name:=Filename
End Sub
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. Note that a line that is preceded by
an apostrophe introduces a comment in the code--comments are provided to
explain what the code is doing at a particular point in the procedure. Note
also that an underscore character (_) indicates that code continues from
one line to the next. You can type lines that contain this character as one
logical line or you can divide the lines of code and include the line
continuation character.
Microsoft has confirmed this to be a problem in the Microsoft products that are listed at the beginning of this article.
In Microsoft Project, if you open a project using the Open dialog box while the project is already open, the project is activated and no error message appears. However, if you use the FileOpen method in a macro to open a project file, and the project is already open, the project is activated, but you receive an error message.
Sub Open_File
FileOpen Name:="TEST.MPP"
End Sub Run-time error '1004':
Command could not be completed successfully
For more information about the FileOpen method, choose the Search button in Help and type:
FileOpen
Additional query words:
Keywords :
Issue type : kbbug
Technology : kbHWMAC kbOSMAC kbProjectSearch kbProject400Mac kbProjectMacSearch kbProject400
|
Last Reviewed: November 5, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |