Macro works on Excel 2003 not Excel 2007

nerojr

New Member
Joined
May 18, 2009
Messages
31
I have a macro that pulls various sheets from one location and compiles them on a new workbook. This code worked flawlessly in 03, but it errors out in 2007. I receive the error on the below line marked in red. Any ideas on how to get this fixed? Thanks for you time.

Sub Production()
Dim CurWkbk As Workbook
Application.DisplayAlerts = False
Application.ScreenUpdating = False
CurPath = "\\Ohcanapp0002\public\Auto Processing\Team Kozenko"
Set fs = Application.FileSearch
With fs
.LookIn = CurPath
.Filename = "*.*"
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
For i = 1 To .FoundFiles.Count
Curname = .FoundFiles(i)
Set Curbook = Workbooks.Open(Curname)
If InStr(1, Curbook.Name, "") > 0 Then

Set CurWkbk = ActiveWorkbook
Call Transfer
CurWkbk.Close SaveChanges:=False
End If
Next i
Else
MsgBox "There were no files found."
End If
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Sub Transfer()
Dim CurWkbk As Workbook
Dim newWkbk As Workbook
Dim ws As Worksheet Set CurWkbk = ActiveWorkbook Set newWkbk = Workbooks("Kozenko.xls")CurWkbk.Worksheets("Time Sheet").Copy before:=newWkbk.Sheets("Master")
Sheets(Trim("Time Sheet")).Name = CurWkbk.Name
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Application.FileSearch was removed in Excel 2007.

If you search this board for filesearch you'll find several workarounds.
 
Upvote 0
Thanks for the quick response! I see from some examples that Dir() should be used in this situation. Any chance someone can walk me through how to update this code? I'm a bit of a novice in VBA.

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

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