ChDir

AussieRob

Board Regular
Joined
Dec 8, 2004
Messages
207
I am having trouble with ChDir.

Code:
Sub FindFileNames()

    Dim ParentName As String
    Dim a As Double
    Dim FilePath As String
    Dim IllegalFileXls As String
    Dim IllegalFileDoc As String
    Dim IllegalFilePdf As String

        For a = 0 To 81

            ParentName = Cells(2 + a, 1)
            FilePath = "M:\2 - Companies\Issuers\" & ParentName & ""
            ChDir FilePath
            IllegalFileXls = Dir("*.xls")
            IllegalFileDoc = Dir("*.doc")
            IllegalFilePdf = Dir("*.pdf")

        Next a

End Sub

The problem is that my search for 'Illegal' .xls, .doc and .pdf is not being conducted on my M drive but rather on my C drive. That is ChDir does not seem to be working.

Thanks

Rob
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
ChDir changes directory within a drive. Use ChDrive to change the drive first, then do ChDir.
 
Upvote 0

Forum statistics

Threads
1,207,281
Messages
6,077,511
Members
446,287
Latest member
tjverdugo85

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top