PRJ41: Error with ConsolidateProjects and Filenames Argument (149951)



The information in this article applies to:

  • Microsoft Project for Windows 95 4.1

This article was previously published under Q149951

SYMPTOMS

In Microsoft Project, when you use the ConsolidateProjects method with wildcards in the FileNames argument, you may receive an error similar to the following:
Run-time error '1004': Filename not valid

WORKAROUND

Microsoft provides examples of Visual Basic for Applications 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. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

To avoid this problem, build a string variable, then pass the string variable to the FileNames argument. The following code demonstrates how to change to the folder where the Project files to be consolidated are located and loops through each file based on a wildcard directory search.

The following code has a limit of 255 characters in the file name string.

Visual Basic Code Example

Sub ProjNames()
    dir_string = "C:\winproj"  ' Enter your directory path here
    ChDir (dir_string)         ' This switches to the above entered
                               ' directory
    f = Dir("*.MPP")           ' This returns the first filename that
                               ' applies to the wildcard search
    Do While Len(f) > 0        ' Loop until the last file name has been
                               ' returned
        file_string = file_string & f & ","
                               ' Adds the new filename, and a comma
        f = Dir()              ' Returns the next file
    Loop
    file_string = Left(file_string, Len(file_string) - 1)
                               ' This strips the last comma off
    ConsolidateProjects FileNames:=file_string, hidesubtasks:=False
End Sub
				

STATUS

Microsoft has confirmed this to be a problem in the versions of Microsoft Project listed above.

REFERENCES

For additional information, please see the following article in the Microsoft Knowledge Base:

149491 PRJ4: ConsolidateProjects Method: 255 Character Limit For Filenames


Modification Type:MajorLast Reviewed:8/30/2002
Keywords:kbbug kberrmsg KB149951