What I want to do is more complex than selecting a file from a list of files. I will start in a directory, then I want to change to the most recently modified directory. I then want to repeat that process in a sub-directory, and then, inside of that, I want to select the most recently modified excel file and open it.
我想要做的比从文件列表中选择文件更复杂。我将从一个目录开始,然后我想更改为最近修改的目录。然后我想在子目录中重复该过程,然后,在其中,我想选择最近修改的excel文件并打开它。
What is the best approach to do this?
这样做的最佳方法是什么?
What objects / methods should I be looking into?
我应该研究哪些对象/方法?
1 个解决方案
#1
17
The simplest function is
最简单的功能是
FileDateTime(pathname)
where pathname can be a directory for folder.
其中pathname可以是文件夹的目录。
Alternatively, you can use the FileSystemObject object, DateLastModified property:
或者,您可以使用FileSystemObject对象,DateLastModified属性:
Dim fileModDate As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(<filenamestringhere>)
fileModDate = f.DateLastModified
All of the above can be explored in VBA help.
以上所有内容都可以在VBA帮助中进行探讨。
#1
17
The simplest function is
最简单的功能是
FileDateTime(pathname)
where pathname can be a directory for folder.
其中pathname可以是文件夹的目录。
Alternatively, you can use the FileSystemObject object, DateLastModified property:
或者,您可以使用FileSystemObject对象,DateLastModified属性:
Dim fileModDate As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(<filenamestringhere>)
fileModDate = f.DateLastModified
All of the above can be explored in VBA help.
以上所有内容都可以在VBA帮助中进行探讨。