R
Red
All help is appreciated as I'm now rapidly going mad!
I'm trying to read all mpp files in directory f:\ which has several sub
directories. The first loop I've written runs through the first level of
directories and works fine on its own. The second loop uses the first to run
through all the subdirectories and also works fine on it's own. But put the
2 together and I get Error 5, Invalid Procedure, Call or Argument on line
Portfolio = Dir. I don't understand!!
' Display the names in Project_plans that represent directories.
RootPath = "f:\PD Portfolios\" ' Set the path.
Portfolio = Dir(RootPath, vbDirectory) ' Retrieve the first entry.
Do While Portfolio <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If Portfolio <> "." And Portfolio <> ".." Then
' Use bitwise comparison to make sure Portfolio is a directory.
If (GetAttr(RootPath & Portfolio) And vbDirectory) = vbDirectory
Then
JobPath = RootPath & Portfolio & "\"
JobType = Dir(JobPath, vbDirectory)
Do While JobType <> "" ' Start the loop
If JobType <> "." And JobType <> ".." Then
' Use bitwise comparison to make sure Portfolio is a
directory.
If (GetAttr(JobPath & JobType) And vbDirectory) =
vbDirectory Then
Debug.Print Portfolio ' Display entry only if it
End If ' It represnet s a directory
End If
JobType = Dir
Loop
End If ' it represents a directory
End If
Portfolio = Dir ' Get next entry.
Loop
I'm trying to read all mpp files in directory f:\ which has several sub
directories. The first loop I've written runs through the first level of
directories and works fine on its own. The second loop uses the first to run
through all the subdirectories and also works fine on it's own. But put the
2 together and I get Error 5, Invalid Procedure, Call or Argument on line
Portfolio = Dir. I don't understand!!
' Display the names in Project_plans that represent directories.
RootPath = "f:\PD Portfolios\" ' Set the path.
Portfolio = Dir(RootPath, vbDirectory) ' Retrieve the first entry.
Do While Portfolio <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If Portfolio <> "." And Portfolio <> ".." Then
' Use bitwise comparison to make sure Portfolio is a directory.
If (GetAttr(RootPath & Portfolio) And vbDirectory) = vbDirectory
Then
JobPath = RootPath & Portfolio & "\"
JobType = Dir(JobPath, vbDirectory)
Do While JobType <> "" ' Start the loop
If JobType <> "." And JobType <> ".." Then
' Use bitwise comparison to make sure Portfolio is a
directory.
If (GetAttr(JobPath & JobType) And vbDirectory) =
vbDirectory Then
Debug.Print Portfolio ' Display entry only if it
End If ' It represnet s a directory
End If
JobType = Dir
Loop
End If ' it represents a directory
End If
Portfolio = Dir ' Get next entry.
Loop