Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Locating Latest Workbook

Hi,
Which command do I use to locate the latest workbook in A Folder,

I have a series of Excel workbooks, they are named by the date they were saved
i.e. List 01-12-04
List 08-12-04
List 15-12-04 etc.etc.
So Far I have

sub fold()

dim i

i = C:\My Documents\Workbooks.Count
MsgBox C:\My Documents\Workbooks(i)

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Locating Latest Workbook

Hi

Function LatestFile(Folder As String, _
sType As String) As String
Dim Dt As Date
Dim NextFile As String
NextFile = Dir(Folder & "\" & sType)
Do Until NextFile = ""
If FileDateTime(Folder & "\" & NextFile) Dt Then _
LatestFile = NextFile
NextFile = Dir()
Loop
End Function

Sub test()
MsgBox LatestFile("C:\Temp", "*.*")
MsgBox LatestFile("C:\Temp", "*.rtf")
MsgBox LatestFile("C:\Temp", "*.xl*")
End Sub

HTH. Best wishes Harald

"teresa" skrev i melding
...
Hi,
Which command do I use to locate the latest workbook in A Folder,

I have a series of Excel workbooks, they are named by the date they were

saved
i.e. List 01-12-04
List 08-12-04
List 15-12-04 etc.etc.
So Far I have

sub fold()

dim i

i = C:\My Documents\Workbooks.Count
MsgBox C:\My Documents\Workbooks(i)

End Sub




Reply
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
Latest Taxation Books available at jain book depot LATEST BOOKRELEASES JACK ANDERSON Excel Worksheet Functions 0 May 29th 10 01:25 PM
Locating if a Sheet is present in a workbook Shane Excel Discussion (Misc queries) 3 October 29th 09 08:20 PM
Locating a Worksheet from another Workbook Walter Excel Worksheet Functions 12 March 13th 09 07:59 PM
LOCATING A CHART SAVED IN A WORKBOOK FLKULCHAR Excel Discussion (Misc queries) 0 June 24th 05 05:26 AM
Find a workbook and "overwrite it with the latest Excel format" PSKelligan Excel Programming 2 October 26th 04 01:45 PM


All times are GMT +1. The time now is 12:13 AM.

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

About Us

"It's about Microsoft Excel"