PDA

View Full Version : Runtime error 445, need help



geebra
03-14-2014, 10:29 AM
I recently updated to Office 2010 and some of my previous macro are not working and I have received runtime error 445. I did some reaseach and realized that it no longer support the Application.Filesearch.


Sub listbox_onstart()
Dim fsDim i As Integer
Dim stlen As Integer
Set fs = Application.FileSearch
With fs
.LookIn = ActiveWorkbook.Path
.filename = "*.rpt"
ListBox1.Clear
If .Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending) > 0 Then
stlen = Len(ActiveWorkbook.Path) + 2
For i = 1 To .FoundFiles.Count
ListBox1.AddItem Mid(.FoundFiles(i), stlen)
Next i
End If
End With
End Sub

Can you guys help me edit this to get it working again?Thankssorry guys I tried putting it in a easier to read format, but it is not letting me. My apologies

Bob Phillips
03-14-2014, 11:19 AM
Cross-posted at ExcelGuru http://www.excelguru.ca/forums/showthread.php?2788-Runtime-error-445-need-help

geebra
03-14-2014, 11:56 AM
The poster from excelguru gave me some ideas, but I am unable to compile all together to make it work. Any help is appreciated! Thanks

SamT
03-14-2014, 07:25 PM
Dim filename As String

stlen = Len(ActiveWorkbook.Path) + 2
filename = Dir(activeworkbookpath & Application.PathSeparator & "*.rpt")

Do While filename <> ""
ListBox1.AddItem Mid(FileName, stlen)
filename = Dir
Loop