Application.FileSearch not in XL2007?

jmthompson

Well-known Member
Joined
Mar 31, 2008
Messages
966
Good morning,
Several months ago, with the help of several MRExcel buddies, I crafted some complicated macros. The following is one step from these macros. This step looks for a file in a specific folder using Application.FileSearch. This application does not appear to be supported in 2007. Is there a workaround? I can provide the full macro, if needed.

Regards,


Code:
Function OpenCsv(MyCSVPath As String, CSVFileName As String, CurBook As Worksheet, _<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
    BValue As String, SaveAsPath As String) As Boolean<o:p></o:p>
'------------------------------------------<o:p></o:p>
'DEFINE VARIABLES<o:p></o:p>
'------------------------------------------<o:p></o:p>
Dim SrceBook As Workbook<o:p></o:p>
Dim lastRow As Long, lastRowWFO As Long<o:p></o:p>
'------------------------------------------<o:p></o:p>
'SET SPECIFIC HANDLER<o:p></o:p>
'------------------------------------------<o:p></o:p>
On Error GoTo Err_OpenCsv<o:p></o:p>
'------------------------------------------<o:p></o:p>
'OPEN PARSED FILE<o:p></o:p>
'------------------------------------------<o:p></o:p>
With Application.FileSearch<o:p></o:p>
    .NewSearch<o:p></o:p>
    .LookIn = MyCSVPath<o:p></o:p>
    .FileType = msoFileTypeAllFiles<o:p></o:p>
    .Filename = CSVFileName<o:p></o:p>
    .Execute<o:p></o:p>
     Set SrceBook = Workbooks.Open(.FoundFiles(1))<o:p></o:p>
End With<o:p></o:p>
'------------------------------------------<o:p></o:p>
'RESET HANDLER<o:p></o:p>
'------------------------------------------<o:p></o:p>
On Error GoTo 0<o:p></o:p>
'------------------------------------------<o:p></o:p>
'SET PASTE ROW + LAST ROW IN SOURCE FILE<o:p></o:p>
'------------------------------------------<o:p></o:p>
lastRowWFO = CurBook.Cells(Rows.Count, "A").End(xlUp).Row + 1<o:p></o:p>
SrceBook.ActiveSheet.Name = "Sheet1"<o:p></o:p>
lastRow = SrceBook.Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row<o:p></o:p>
JobDate = SrceBook.Worksheets("Sheet1").Cells(3, 1)<o:p></o:p>
JobNum = SrceBook.Worksheets("Sheet1").Cells(2, 1)<o:p></o:p>
CurBook.Activate<o:p></o:p>
Dim c As Range<o:p></o:p>
        For Each c In Range([A4], Cells(Rows.Count, "A").End(xlUp))<o:p></o:p>
            If c = JobDate And c.Offset(, 1) = BValue And c.Offset(, 2) = JobNum Then GoTo Dupe<o:p></o:p>
        Next c
<o:p></o:p>
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try replacing:

Code:
With Application.FileSearch<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
    .NewSearch<o:p></o:p>
    .LookIn = MyCSVPath<o:p></o:p>
    .FileType = msoFileTypeAllFiles<o:p></o:p>
    .Filename = CSVFileName<o:p></o:p>
    .Execute<o:p></o:p>
     Set SrceBook = Workbooks.Open(.FoundFiles(1))<o:p></o:p>
End With<o:p></o:p>

with:

Code:
Set SrceBook = Workbooks.Open(MyCSVPath & "\" & CSVFileName)<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,795
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top