View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Enohp Aikon Enohp Aikon is offline
external usenet poster
 
Posts: 8
Default Return most recent file in subdirectory with out using FileSea

<I think you will find your own name is very easy to remember.
Yes, it took some time, but I think I got it memorized (for now). :-)
There are a few places though, where I don't want to use my real name and/or
email address as a log-on (ie: online banking), hence the easy to remember
log-on alias. Its almost Alzheimer-proof so it should be good a few more
years.

Most importantly, thanks for the Windows Script-Host help file link. It
appears that the this is a powerful tool that I need to learn how to use.

I am curious, is there away to use VBA to create a reference to the
scrrun.dll programmatically?

In any event, many thanks to both you and RBS for sharing both your
knowledge and time to help.



"Jim Cone" wrote:

EA,

The Windows Script Host / FileSystemObject is part of Windows and
is included with all Windows systems released after Windows 95.
The help file is found here...
http://msdn.microsoft.com/library/de...ist/webdev.asp

I think you will find your own name is very easy to remember.

Jim Cone
San Francisco, USA


"Enohp Aikon"

wrote in message

<nokia phone Yes, so many places that need a user name - I needed one that
is easy to remeber
Thanks Jim,
I though there must be a way to use the scripting object but I am not
familiar with it and the €œhelp€ in Excel is lame. This works great but my
only concern is many different users and computers will be using this file
and I will not know if a reference to the scripting DLL will exist. Thoughts?




"Jim Cone" wrote:
nokia phone?,

'----------------------------
Sub LatestFile()
'Jim Cone - San Francisco, USA - June 02, 2005
'Requires a project reference to "Microsoft Scripting Runtime" (scrrun.dll)
'Displays the latest file name in the strPath folder.
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim objFile As Scripting.File
Dim strPath As String
Dim strName As String
Dim varDate As Variant
' Specify the folder...
strPath = "C:\Program Files\Microsoft Office\Office"
Set objFSO = New Scripting.FileSystemObject
Set objFolder = objFSO.GetFolder(strPath)
For Each objFile In objFolder.Files
If objFile.DateLastModified varDate Then
varDate = objFile.DateLastModified
strName = objFile.Name
End If
Next 'objFile
MsgBox strName & " - is latest file - " & varDate
Set objFSO = Nothing
Set objFolder = Nothing
Set objFile = Nothing
End Sub
'-------------------------------




"Enohp Aikon"

wrote in message

The file search object does not work properly on all platforms. This is a
known issue but the workarounds provided in article 305342 do not resolve the
problem when using a local hard drive mapped to €œK:€. I need
recommendations for returning the most recent file in a subdirectory with out
using the FileSearch object.
The following code works as expected except when using Office XP with
Windows 2000.
------------------------------------------------------------------------------
With Application.FileSearch
..Newsearch
..Lookin = €œK:\€
..SearchSubFolders = false

NumFound = .Execute(SortBy: msoSortByLastModified, _
SortOrder: = msoSortOrderDescending _
AlwaysAccurate = True)

If NumFound 0 then NewestFile = FilesFound(1)
-------------------------------------------------------------------------------
I need code that works on any combination of Office 2000 and above with
Window 2000 and above. The code above is generic and I will actually be
using a function.
Thanks