J
JEFF
Hello,
In the past, I was able to make the code below work. In using it against a
different folder, it works, but stops after 18 files (there are 45 in the
folder, all identical except for their names, which follow the exact same
naming scheme)..... I don't get an error, it just acts like it is done.
Any clues?
TIA!
Dim FSO As Object
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object
Dim oWb As Workbook
Dim sFolder As String
Set FSO = CreateObject("Scripting.FileSystemObject")
'*** THE FOLDER I WANT TO WORK IN ******************
sFolder = "Y:\Sales\Forecast Workbooks"
' *************************************************
If sFolder <> "" Then
Set Folder = FSO.GetFolder(sFolder)
Set Files = Folder.Files
For Each file In Files
If file.Type = "Microsoft Excel Worksheet" Then
Set oWb = Workbooks.Open(Filename:=file.Path)
**********************************************************
Do something
**********************************************************
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
Next file
End If
End Sub
In the past, I was able to make the code below work. In using it against a
different folder, it works, but stops after 18 files (there are 45 in the
folder, all identical except for their names, which follow the exact same
naming scheme)..... I don't get an error, it just acts like it is done.
Any clues?
TIA!
Dim FSO As Object
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object
Dim oWb As Workbook
Dim sFolder As String
Set FSO = CreateObject("Scripting.FileSystemObject")
'*** THE FOLDER I WANT TO WORK IN ******************
sFolder = "Y:\Sales\Forecast Workbooks"
' *************************************************
If sFolder <> "" Then
Set Folder = FSO.GetFolder(sFolder)
Set Files = Folder.Files
For Each file In Files
If file.Type = "Microsoft Excel Worksheet" Then
Set oWb = Workbooks.Open(Filename:=file.Path)
**********************************************************
Do something
**********************************************************
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
Next file
End If
End Sub