Thanks for below.  It works great.  How do I get the file to open after it
locates the current file?

On Thu, Feb 5, 2009 at 11:41 AM, Paul Schreiner <schreiner_p...@att.net>wrote:

> This should work:
>
> Option Explicit
> Sub lastest_file()
>     Dim LastFileName, LastFileDate
>     Dim fso, Folder, f, Files, File
>     Set fso = CreateObject("Scripting.FileSystemObject")
>     Folder = "c:\temp3\"
>     Set f = fso.getfolder(Folder)
>     Set Files = f.Files
>     LastFileDate = 0
>     For Each File In Files
>         If (fso.getextensionname(File.Path) = "xls") Then
>             If File.datelastmodified > LastFileDate Then
>                 LastFileDate = File.datelastmodified
>                 LastFileName = File.Name
>             End If
>         End If
>     Next File
>     MsgBox "Last file: " & LastFileName
> End Sub
>
> Paul
>
>  ------------------------------
> *From:* Joe Wilson <jhwilson1...@gmail.com>
> *To:* excel-macros@googlegroups.com
> *Sent:* Thursday, February 5, 2009 9:35:30 AM
> *Subject:* $$Excel-Macros$$ How to open a file based on newest file in
> folder
>
> Hello group.
>
> Does anyone know of a way using VBA code that would allow me to open a file
> based on the file being the last saved file in a folder?  IT saves a file
> for me but adds a time stamp to the file name, which will not allow me to
> open the file based on the file name.
>
> Any help would be appreciated.
>
> Thanks,
>
> Joe
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
Visit the blog to download Excel tutorials at 
http://www.excel-macros.blogspot.com

To post to this group, send email to excel-macros@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/excel-macros?hl=en

Visit & Join Our Orkut Community at 
http://www.orkut.com/Community.aspx?cmm=22913620

To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com

To see the Daily Excel Tips, Go to:
http://exceldailytip.blogspot.com
 
If you find any spam message in the group, please send an email to Ayush @ 
jainayus...@gmail.com
-~----------~----~----~----~------~----~------~--~---

Reply via email to