gpt4 book ai didi

vba - 将创建的文件日期添加到列表中

转载 作者:行者123 更新时间:2023-12-04 20:12:30 29 4
gpt4 key购买 nike

我一直在尝试编辑一些代码,它给出了所有子文件夹中所有文件的列表,也给了我在下一列中创建的日期,但我不确定如何。这是我正在使用的代码:它可以很好地获取文件路径,但不能获取文件 DateCreateds

 Sub startIt()

Dim FileSystem As Object
Dim HostFolder As String

HostFolder = "C:\folderthing"

Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)

End Sub

Sub DoFolder(Folder)


Dim SubFolder
For Each SubFolder In Folder.SubFolders
DoFolder SubFolder
Next

i = Cells(Rows.Count, 1).End(xlUp).Row + 1
Dim File
For Each File In Folder.Files
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 1), Address:= _
File.Path, TextToDisplay:=File.Path
ActiveSheet.Add TextToDisplay:=File.DateCreated

i = i + 1

Next


End Sub

最佳答案

如果您想要 列中的日期乙 , 然后:

Sub startIt()

Dim FileSystem As Object
Dim HostFolder As String

HostFolder = "C:\TestFolder"

Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)

End Sub

Sub DoFolder(Folder)


Dim SubFolder
For Each SubFolder In Folder.SubFolders
DoFolder SubFolder
Next

i = Cells(Rows.Count, 1).End(xlUp).Row + 1
Dim File
For Each File In Folder.Files
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 1), Address:= _
File.Path, TextToDisplay:=File.Path
Cells(i, 2).Value = File.DateCreated

i = i + 1

Next


End Sub

enter image description here

关于vba - 将创建的文件日期添加到列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35205588/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com