Dzwebs.Net

撰写电脑技术杂文十余年

VBA获取文件的最后修改时间

Admin | 2014-12-3 10:56:54 | 被阅次数 | 10644

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

  下面的VBA代码功能是,获取指定位置的文件的最后的修改时间。

  With Application.FileSearch
  .NewSearch
  .LookIn = "F:/ttt"
  .Filename = "*.xls"
  .SearchSubFolders = True
  .FileType = msoFileTypeAllFiles
  If .Execute() > 0 Then
  For i = 1 To .FoundFiles.Count
  Worksheets("sheet3").Cells(i, 2).Value = .FoundFiles(i)
  Dim fs, f, s
  Set fs = CreateObject("Scripting.FileSystemObject")
  Set f = fs.GetFile(.FoundFiles(i))
  s = "Created: " & f.DateCreated
  Worksheets("sheet3").Cells(i, 3).Value = s
  Set f = Nothing
  Set fs = Nothing
  Next i
  Else
  MsgBox "文件未能找到!"
  End If
  End With


该杂文来自: Excel杂文

上一篇:Excel文本转数字的简单方法

下一篇:excel weekunm

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计