Excel VBA: Application.FileSearch Error
Solved/Closed
w_l
Posts
1
Registration date
Monday June 10, 2013
Status
Member
Last seen
June 10, 2013
-
Jun 10, 2013 at 03:31 AM
wliang Posts 41 Registration date Thursday June 16, 2011 Status Member Last seen May 7, 2014 - Oct 8, 2013 at 04:39 AM
wliang Posts 41 Registration date Thursday June 16, 2011 Status Member Last seen May 7, 2014 - Oct 8, 2013 at 04:39 AM
Related:
- Application.filesearch
- Number to words in excel formula without vba - Guide
- Vba case like - Guide
- Excel marksheet - Guide
- How to open vba in excel - Guide
- Excel apk for pc - Download - Spreadsheets
2 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jun 16, 2013 at 10:13 AM
Jun 16, 2013 at 10:13 AM
It is saying there is no such thing in "Application" object called "FileSearch" I am guessing it is 2003 or older macro that you are trying to run to 2007 and above
You can change the code to DIR or use FileSystemObject
DISCLAIMER : ******* NOT TESTED ****************
you can try this
in place of
You can change the code to DIR or use FileSystemObject
DISCLAIMER : ******* NOT TESTED ****************
you can try this
Dim fileName As String fileName = Dir(fldrpath & "\" & "*.xls") Do While fileName <> vbNullString If Left(Right(fileName, 8), 4) > Left(Right(newest0, 8), 4) Then newest0 = fileName End If fileName = Dir Loop V(1) = newest0 V(2) = Yr scrapnewest = V
in place of
With Application.FileSearch .NewSearch .LookIn = fldrpath .SearchSubFolders = False .fileName = "*.xls" .MatchTextExactly = False If .Execute() > 0 Then For I = 1 To .FoundFiles.Count 'foundfiles with ending .xls If Left(Right(.FoundFiles.Item(i), 8), 4) > Left(Right(newest0, 8), 4) Then newest0 = .FoundFiles.Item(i) End If Next i End If V(1) = newest0 V(2) = Yr scrapnewest = V End With
wliang
Posts
41
Registration date
Thursday June 16, 2011
Status
Member
Last seen
May 7, 2014
Oct 8, 2013 at 04:39 AM
Oct 8, 2013 at 04:39 AM
Sorry for the late reply.
Thanks, rizvisa1. This problem is resolved now.
Thanks, rizvisa1. This problem is resolved now.