Excel VBA Tool To Get File Properties
- File Name
- Date Created
- Date Last Accessed
- Date Last Modified
- Size (MB)
You just need to browse the folder where your files are and click on ‘Get File Properties’ button
'This function loops through all the files in the folder and 'gets the properties of each file and displays them on the sheet Public Sub GetFileProperties() 'Variable Declaration Dim objFS As Object Dim objFile As Object Dim strPath As String Dim vFile As Variant Dim iCurRow As Integer 'Clear old data from the sheet Sheet1.Range("C7:H" & Sheet1.Rows.Count).ClearContents 'Set the path of the folder strPath = Sheet1.Range("C3").Value 'Add slash at the end of the path If Right(strPath, 1) <> "/" And Right(strPath, 1) <> "\" Then strPath = strPath & "\" End If 'Set Directory to folder path ChDir strPath vFile = Dir(strPath & "*.*") 'Change or add formats to get specific file types 'Set the variable to FileSystemObject Set objFS = CreateObject("Scripting.FileSystemObject") iCurRow = 7 Do While vFile <> "" 'LOOP until all files in folder strPath have been looped through Set objFile = objFS.getfile(vFile) 'File name Sheet1.Cells(iCurRow, 3).Value = objFile.Name 'Date Created Sheet1.Cells(iCurRow, 4).Value = objFile.DateCreated 'Date Last Accessed Sheet1.Cells(iCurRow, 5).Value = objFile.DateLastAccessed 'Date Last Modified Sheet1.Cells(iCurRow, 6).Value = objFile.DateLastModified 'Size Sheet1.Cells(iCurRow, 7).Value = Round(objFile.Size / 1024 / 1024, 2) 'Type Sheet1.Cells(iCurRow, 8).Value = objFile.Type vFile = Dir iCurRow = iCurRow + 1 Loop End Sub
How to use Excel VBA Tool to get file properties:-
- Click on ‘Get File Properties’ button
- Done, you will get all the files available in the folder along with file properties
- To clear the data, click on ‘Clear Data’
Note: ExcelSirJi team works hard to help it’s subscribers and visitors to make full use of the free templates. As part of this objective, you are free to use this template. To get unprotected copy, you may refer the below link.
Excel VBA Course : Beginners to Advanced
We are currently offering our Excel VBA Course at discounted prices. This courses includes On Demand Videos, Practice Assignments, Q&A Support from our Experts. Also after successfully completion of the certification, will share the success with Certificate of Completion
This course is going to help you to excel your skills in Excel VBA with our real time case studies.
Lets get connected and start learning now. Click here to Enroll.
Secrets of Excel Data Visualization: Beginners to Advanced Course
Here is another best rated Excel Charts and Graph Course from excelsirji. This courses also includes On Demand Videos, Practice Assignments, Q&A Support from our Experts.
This Course will enable you to become Excel Data Visualization Expert as it consists many charts preparation method which you will not find over the internet.
So Enroll now to become expert in Excel Data Visualization. Click here to Enroll.