Wildcard a file in a folder and get the update date and time

Asked 2 years ago, Updated 2 years ago, 50 views

Thank you for your help.
In the EXCEL VBA,
file in a folder (C:\TEST\test1234.txt) in an if statement. If wildcarding (test*.*) equals, update the date and time of the file
I would like to implement the method of obtaining it.

In the method described below, test 1234.txt=test*.* is determined to be false and
get the update date and time It does not go through the routing

Is there a way to implement these specifications?

Subfiledate()

Dim fname As String'

Cell (1,2) in 'word is entered as test*.*
fname=Works("work").Cells(1,2)

Set fso=CreateObject("Scripting.FileSystemObject")

Set fl=CreateObject("Scripting.FileSystemObject")
Get the Set fl=fso.GetFolder("C:\TEST")' folder
US>'The above C:\TEST contains test1234.txt

Setf=CreateObject("Scripting.FileSystemObject")
Retrieve files in For Each f Infl.Files' folder
    If.Name = fname Then' file you want to get the date and time
        Dim As Date
        d=f. Get DateLastModified' update date and time
    End If
Next

Worksheets("check").Range("H27") =d
Worksheets("check").Activate
Worksheets("check").Range("A1").Select

vba excel

2022-09-29 22:16

1 Answers

If.Name=fname Then

If.Name Like fname Then

If you change it to , you can get it.


2022-09-29 22:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.