alateos
asked on
File manipulation with VBA
Hi,
I would like to be able to change file attributes using vba. Also, I would like to see creation date and last accessed date.
Here's an example of what I'd like to do with my code:
1) Change attribute of a file to hidden, read-only, or archive
2) Get the last access date of the file or last modified date.
I would like this code to run for all files in a folder X.
I would like to be able to change file attributes using vba. Also, I would like to see creation date and last accessed date.
Here's an example of what I'd like to do with my code:
1) Change attribute of a file to hidden, read-only, or archive
2) Get the last access date of the file or last modified date.
I would like this code to run for all files in a folder X.
>For last modified date, you should consider the FileSystemObject...
Meant to be last access date... FileSystemObject can get all the different types of file date/time stamps:
Example:
Dim fso, file, createdate
Set fso= CreateObject("Scripting.Fi leSystemOb ject")
Set file= fso.GetFile("C:\temp\test. txt")
msgbox "Created " & file.DateCreated
msgbox "Modified " & file.DateLastModified
msgbox "Last accessed " & file.DateLastAccessed
Meant to be last access date... FileSystemObject can get all the different types of file date/time stamps:
Example:
Dim fso, file, createdate
Set fso= CreateObject("Scripting.Fi
Set file= fso.GetFile("C:\temp\test.
msgbox "Created " & file.DateCreated
msgbox "Modified " & file.DateLastModified
msgbox "Last accessed " & file.DateLastAccessed
ASKER
thanks for your reply Paul... could you please show me a full practical example... where the app looks through a folder... also please show how one can set the attribute in the example
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
example:
SetAttr Path, vbHidden Or vbSystem
2. Use FileDateTime, which returns date created or modified
Dim dt as Date
dt = FileDateTime(Path)
For last modified date, you should consider the FileSystemObject...