Michael M
Well-known Member
- Joined
- Oct 27, 2005
- Messages
- 21,895
- Office Version
- 365
- 2019
- 2013
- 2007
- Platform
- Windows
Hi All
I've looked at this for a couple of hours now....and it's finally done my head, I can't see the error in the Activeworkbook.SaveAs line, where it is failing
Any assistance to ease my pain would be appreciated.
I've looked at this for a couple of hours now....and it's finally done my head, I can't see the error in the Activeworkbook.SaveAs line, where it is failing
Code:
Sub LoopFolders()
Dim oFSO
Dim Folder As Object, Files As Object, file As Object, ws As Worksheet, fldr
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set Folder = oFSO.GetFolder("D:\Temp\Alco Tests")
For Each file In Folder.Files
If file.Type Like "*Comma Separated*" Then
Workbooks.Open Filename:=file.Path
Call Process
Application.DisplayAlerts = False
For Each ws In Worksheets
If ws.Name Like "Sheet*" Then
ws.Delete
End If
Next ws
ActiveWorkbook.SaveAs Filename:=file, FileFormat:=56
End If
ActiveWorkbook.Close
Next file
Set oFSO = Nothing
Application.DisplayAlerts = True
End Sub
Any assistance to ease my pain would be appreciated.