【问题标题】:Using VBA to list folders and properties(date last modified)使用 VBA 列出文件夹和属性(上次修改日期)
【发布时间】:2016-10-21 14:39:12
【问题描述】:

我在下面列出了一个 VBA 代码,其中列出了父文件夹中的所有文件夹名称。我正在尝试另外列出文件夹属性,特别是“上次修改日期”。我知道这对于文件夹中的文件是可能的,但在这种情况下,它是我需要的文件夹。

我尝试使用 FileSystemObject,但我遇到了问题,不确定我的原始代码是否是问题所在。

有人可以帮助我指导我接下来可以做什么。

这是我的原始代码:

Sub GetFolders()
Dim path As String
Dim folder As String
Dim row As Integer


path = "\\C:bla bla\"
folder = Dir(path, vbDirectory)
row = 1

Do While folder <> ""
If (GetAttr(path & folder) And vbDirectory) = vbDirectory Then
    Cells(row, 1) = path & folder
    row = row + 1
End If
folder = Dir()
Loop

End Sub

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    FileDateTime() 可以做到这一点。

    循环内部:

    Cells(row, 1) = path & folder
    If (folder <> "." And folder <> "..") Then
        Cells(row, 2) = FileDateTime(path & folder)
    End If
    row = row + 1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-14
      • 2021-10-08
      • 2017-01-02
      相关资源
      最近更新 更多