Unable to change Directories in Macro


Posted by Michael on January 17, 2002 6:02 AM

Here is My code:

Sheets("Main Menu").Select
Sheets("Main Menu").Activate
Worksheets("Main Menu").Unprotect
ChDrive "X:\"
ChDir "X:\MaryYoung\ProccostExcel\NorthCarolina"
With Application.FileSearch
.Execute
For lngCellCounter = 1 To .FoundFiles.Count
Cells(lngCellCounter, 10) = .FoundFiles(lngCellCounter)
Next lngCellCounter
End With
ChDrive "X:\"
ChDir "X:\MaryYoung\LBSRECExcelPages\NorthCarolina"
Run ("GetLBSRECFiles")
(Where the "GetLBSRECFiles" executes the same file find as above)

The problem is that the macro doesn't recognize the second Directory chage, Both of the Find File instances give the exact same results for the First directory change. Does anybody have any suggestions.
I tried putting the Second Find File code in a seperate macro with a call out in the first to it (The way the code looks now). But that didn't help any. Any suggestions would be greatly appreciated.



Posted by Russell Hauf on January 17, 2002 8:28 AM

Instead of changing directories outside of your filesearch, try something like this:

With Application.FileSearch
.NewSearch ' (this may be the key to your problem)
.Lookin = "X:\MaryYoung\LBSRECExcelPages\NorthCarolina"
' blah blah blah
End With

----------------

Hope this helps,

Russell