"DIR" Command not working

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
232
Office Version
  1. 365
Platform
  1. Windows
Using Office 365 Excel

I enter into Immediate Box
Code:
Dir ("E:")
and I get back "180601 Temp RIBBON CALLS.BAS" which isn't even a file in E:.

I add
Code:
Dir ("E:*.*)"
and I get bck the same thing.

If I use
Code:
Dir("E:*.Bat")
Nothing shows but there is one "*.Bat" file in the directory.

Any idea of what's going on here?

Thanks,
Mac
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
For sure you're going to have a problem because you are missing the \
 
Upvote 0
When I do "Dir("c:\Program Files")", i get back is "- Program Files.lnk". And
"C:\*.* "
gives back
".crusader"
when there are 3 other files there.

It use to give me a list of all the files. What's happening?

But thanks for the reply.
Mac
 
Upvote 0
Dir only gives you 1 file at a time. To see all of them, you need to use it in a loop, like this:

Code:
    str1 = Dir("C:\Folder\*.*")
    While str1 <> ""
        Debug.Print str1
        str1 = Dir()
    Wend
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,257
Members
448,880
Latest member
aveternik

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