Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() I have tried to do some research but with no luck. I am trying to create a macro that will open the most recent file with particular filename strings. Another team saves files to a shared directory with the following filenames: TEST_1.DDMMYYYYHHMM TEST_2.DDMMYYYYHHMM The issue is that there may be days that there are no files and there may be days with multiple files. This is what I have thus far: Dim testfile as string Dim count as integer testfile="TEST_1" count=1 Application.FileSearch .NewSearch .LookIn = "B:\" .SearchSubFolders = False .FileName = testfile .Execute Do Until count .FoundFiles.Count If Format(FileDateTime(.FoundFiles(testfile)), "MM/DD/YYYY") < Format(date, "MM/DD/YYYY") Then Set wb = Workbooks.Open(FileName:=.FoundFiles(testfile), ReadOnly:=True) End If Count=count+1 loop End With I think I'm about to go crazy.... any help will be greatly appreciated!! -- kwiklearner ------------------------------------------------------------------------ kwiklearner's Profile: http://www.excelforum.com/member.php...o&userid=31909 View this thread: http://www.excelforum.com/showthread...hreadid=574388 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
mail merging 2 workbooks??? | Excel Discussion (Misc queries) | |||
Open File within a macro | Excel Discussion (Misc queries) | |||
Weird File Open/Save As Behavior | Excel Discussion (Misc queries) | |||
cannot open excel file, please help!!! | Excel Discussion (Misc queries) | |||
Why doesn't the File Open list sort into filename order? | New Users to Excel |