我编写了一个代码来从文件夹中提取文件名,我可以手动选择路径和所有文件名,并提取修改日期。但是,我想要修改代码,以便它只提取那些从Alphabet" A"开始的文件的文件名。以下是代码:
Option Explicit
Function BrowseForFolder(Optional OpenAt As Variant) As Variant
Dim ShellApp As Object
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
Set ShellApp = CreateObject("Shell.Application"). _
BrowseForFolder(0, "Please choose a folder", 0, OpenAt)
On Error Resume Next
BrowseForFolder = ShellApp.self.Path
On Error GoTo 0
Set ShellApp = Nothing
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\rd4470\Documents\Test Folder")
i = 1
For Each objFile In objFolder.Files
Cells(i + 1, 1) = objFile.Name
Cells(i + 1, 2) = objFile.DateLastModified
i = i + 1
Next objFile
Exit Function
Invalid:
BrowseForFolder = False
End Function