具有最新修改日期和文件大小 [英] having the laste modification date and the size of a file

查看:84
本文介绍了具有最新修改日期和文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all;

Hello all;

实际上我正在使用VBA脚本加载存储在特定文件夹中的文件名,并在每个文件中生成超文本链接。

actually I'm using a VBA script to load a name of files stored in a specific folder, and also to generate an hypertext link top each file.

在A列上生成文件名,在B列中生成超文本链接。

the file name is generated on the column A, the hypertext link is generated in column B.

我想添加到此脚本中C列上的"重新修改日期"和"文件大小"。在D列。

i want to add to this script the "laste modification date' on the C column and the "file size" on the D column.

下面我正在使用的脚本

Public nb As Long
Sub Bouton1_Cliquer()
Dim chemin As String
    nb = 0
    chemin = "N:\Folder1"
    Lister chemin
End Sub

Public Function Lister(chemin As String)
Dim fs, Rep, f As Variant, NewRep As String, Nomfich As String
    Set fs = CreateObject("Scripting.FileSystemObject")
        Lister = fs.GetFolder(chemin).Files.Count
        Nomfich = Dir(chemin & "\*.*")
    
    Do While Nomfich <> ""
        nb = nb + 1
        Cells(nb, 1) = Nomfich 'liste dans la feuille de calculs active
        Cells(nb, 2).Hyperlinks.Add Cells(nb, 2), chemin & "\" & Nomfich
        Nomfich = Dir()
    Loop
    'Pour chaque sous-répertoire, appel récursif de Lister
    For Each Rep In fs.GetFolder(chemin).SubFolders
        NewRep = Lister(Rep.Path)
    Next Rep
End Function

请有人帮忙修改它并包含我正在寻找的功能吗?

Please can somebody help modifying it and includes the function that I'm looking for?

推荐答案

这是你如何做的一个例子。

This is an example of how you do it.

Sub Example()
  Dim fso As New Scripting.FileSystemObject  ''Add reference to Microsoft Scripting Runtime
  Dim f As File
  Dim d As Date
  Dim s As Long
  
  Set f = fso.GetFile("C:\temp\myfile.txt")
  d = f.DateLastModified
  s = f.Size
  Debug.Print "Date: " & d & ", Size: " & s
End Sub


这篇关于具有最新修改日期和文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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