How to get the attribute of a directory?

VitaminB6

Board Regular
Joined
Oct 11, 2004
Messages
208
In my macro, I need to get the attribute of a directory, for example, I need to have the date of a directory. Can someone help me with this? Thank you.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Perhaps, something like this:

Sub test()
MsgBox DateValue(FileDateTime("C:\test"))
End Sub
 

VitaminB6

Board Regular
Joined
Oct 11, 2004
Messages
208
Hi HotPepper,

Thank you very much for your reply. This is realy want I am looking for. But, I have another question:
There are several sub-folders in a directory and I would like to run the sub-folders by time. What I mean is to run the sub-folder which time/date is earlier than the others.

In your example, it only shows date but not time. To get the time, TimeValue function can be used. However, is there a function which can get time + date?




Perhaps, something like this:

Sub test()
MsgBox DateValue(FileDateTime("C:\test"))
End Sub
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Code:
Sub test() 
MsgBox FileDateTime("C:\test")
End Sub
 

VitaminB6

Board Regular
Joined
Oct 11, 2004
Messages
208

ADVERTISEMENT

Thank again for your helps.
Below is one of the code and I am trying to seperate the day out. However, I failed.

LotDateForSK = DateValue(FileDateTime(PathForTime & myFileName))

The format of my calander system is 10/17/2006.
Tried to get the month out, below is the code used

Temp=Right(Left(LotDateForSK,4),2) ==>17

However, it fails when the date is 10/9/2006 but ==>/9

Anyone can help me with this?
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
How about:

Code:
Temp = Day(FileDateTime("C:\test"))
 

Forum statistics

Threads
1,136,992
Messages
5,679,018
Members
419,799
Latest member
APInfa

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
Top