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
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