文件每天都会添加到一个文件夹中,它们都包含一个带有“疯狂”的名字,我需要打开最后一个才能执行我的宏。我的代码可以打开文件名包含“mad”的文件,但是它不会打开添加到文件夹中的最新文件:
sub openfilewithnamestring
sFound = Dir(ActiveWorkbook.Path & "\mad*.xlsb") 'should open the latest file added in the folder that constains "MAD" in the name
If sFound <> "" Then
Workbooks.Open Filename:=ActiveWorkbook.Path & "\" & sFound
end if
end sub
例:
MAD0902 16.10.2017
MAD0902 17.10.2017