LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Macro to open most recent file with a particular filename string


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
mail merging 2 workbooks??? Bubba Gump Excel Discussion (Misc queries) 21 August 7th 06 09:13 AM
Open File within a macro Rob Excel Discussion (Misc queries) 10 June 29th 06 08:55 PM
Weird File Open/Save As Behavior [email protected] Excel Discussion (Misc queries) 0 December 9th 05 02:26 AM
cannot open excel file, please help!!! sunlite Excel Discussion (Misc queries) 0 September 5th 05 05:29 PM
Why doesn't the File Open list sort into filename order? cycler New Users to Excel 7 July 16th 05 06:44 PM


All times are GMT +1. The time now is 08:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"