FileSearch, my code is way too slow
Hey Jim,
I may be able to get that to work for me...course, I may have questions
later, but thank you very much for the help.
Jordan
"Jim Cone" wrote:
Jordan,
To run the code provided, you must be using any version of Windows
released after Windows 95. Also, in the VBE, go to the Tools menu and
select "References". In the list of displayed files, find "Microsoft Scripting Runtime"
and check mark it.
That should take care of it.
Regards,
Jim Cone
San Francisco, USA
"Jordan" wrote in message
...
Hey Jim,
Unfortunatly, your code is a bit over my head. The error I get is User
defined type is not defined...how do I get past that?
"Jim Cone" wrote:
Jordan,
See if this does what you want...
'--------------------------------------
Sub LatestDrawingFile()
'Jim Cone - San Francisco, USA - May 19, 2005
'Requires a project reference to "Microsoft Scripting Runtime" (scrrun.dll)
'Required module level "Option Compare Text" statement
'Displays the last alphabetical file name in the strPath folder.
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim objFile As Scripting.File
Dim arrNames() As String
Dim strPath As String
Dim lngNum As Long
' Specify the folder...
strPath = "C:\Program Files\Microsoft Office\Office\Library" '"V:\37\"
Set objFSO = New Scripting.FileSystemObject
Set objFolder = objFSO.GetFolder(strPath)
lngNum = objFolder.Files.Count
ReDim arrNames(1 To lngNum)
lngNum = 1
'Load array with all file names in folder.
For Each objFile In objFolder.Files
arrNames(lngNum) = objFile.Name
lngNum = lngNum + 1
Next 'objFile
'Call descending sort routine.
BubbleSort arrNames()
MsgBox arrNames(1)
Set objFSO = Nothing
Set objFolder = Nothing
Set objFile = Nothing
End Sub
'Modified MSKB code...
'Sort in descending order.
Function BubbleSort(ByRef TempArray() As String)
Dim strTemp As String
Dim i As Long
Dim j As Long
Dim NoExchanges As Integer
Do
NoExchanges = True
For i = 1 To UBound(TempArray) - 1
j = i + 1
'Change "<" to "" to sort ascending.
If TempArray(i) < TempArray(j) Then
NoExchanges = False
strTemp = TempArray(i)
TempArray(i) = TempArray(j)
TempArray(j) = strTemp
End If
Next 'i
Loop While Not NoExchanges
End Function
'-------------------------------------------
-snip-
|