FileSystemObject

フォルダ・ファイルの作成日時を取得する【DateCreatedプロパティ】【FileSystemObject】【ExcelVBA】

構文

Object.DateCreated

DateCreated・・・・指定したObjectの作成日時を取得します。
Fileオブジェクト、Folderオブジェクトへの作成日時を取得します。

DateCreatedプロパティのサンプルコード

Public Sub sample()

    '■FileSystemObjectの宣言
    Dim fso As Object: Set fso = CreateObject("Scripting.FileSystemObject")
    
    '■フォルダの作成日時を取得
    Debug.Print fso.GetFolder("C:\sample").DateCreated
    '例)2022/09/19 09:00:00
    
    '■ファイルの作成日時を取得
    Debug.Print fso.GetFile("C:\sample\sample.txt").DateCreated
    '例)2022/09/19 09:00:00
    
End Sub

注意点

関連記事

コメント

タイトルとURLをコピーしました