问题:我想过滤掉那些包含%Card%.txt的文件名(例如xyz 卡 hij。 txt )我希望列出文件按创建日期降序排列以下是我尝试的代码。
Sub ImportData()
Dim TargetFileDialog As Office.FileDialog
Set TargetFileDialog = Application.FileDialog(msoFileDialogFilePicker)
'Open File Dialog to get File Path
With TargetFileDialog
'User can only imporot one file at a time
.AllowMultiSelect = False
'Auto direct user to specific folder
.InitialFileName = "desiredpath\"
'Add filter
.Filters.Clear
.Filters.Add "All Files", "*.txt", 1
If .Show = -1 Then
For Each TargetFile In .SelectedItems
ImportFile = TargetFile
Next TargetFile
End If
End With
End Sub