添加创建的列表文件日期 [英] Adding file date created to list

查看:156
本文介绍了添加创建的列表文件日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've been trying to edit a bit of code which gives a list of all files in all subfolders to also give me the date created in the next column but am unsure how. Here is the code i'm working with: It gets the file paths fine but not the file 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


推荐答案

我f您希望 B 列中的日期,然后:

If you want the Date in column B, then:

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

这篇关于添加创建的列表文件日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆