I cant seem to figure how to make the code below search thru subfolders, it will search the "strPath" only (original code by Jim Cone).
Any hints, tips or examples are appreciated.
'Opens each .xls file in the folder, makes changes and closes the workbook.
'Protected worksheets throw an error.
'Jim Cone - Portland, Oregon USA
'Modified RS 04.15.14, (Thank you Jim Cone)
Sub RemoveFooter()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim strPath As String
Dim strName As String
Dim WS As Worksheet
Application.ScreenUpdating = False
'Specify the folder...
strPath = "C:\Users\rick\Downloads"
'Use Microsoft Scripting runtime.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPath)
'Check type of file in the folder and open file.
For Each objFile In objFolder.Files
If objFile.Name Like "*.xls" Then
strName = objFile.Name
Workbooks.Open objFile
'Open Workbook
'Clear Footer
For Each WS In Worksheets
WS.PageSetup.LeftFooter = ""
WS.PageSetup.CenterFooter = ""
WS.PageSetup.RightFooter = ""
Next WS
Workbooks(strName).Close savechanges:=True
End If
Next 'objFile
'Cleanup
Application.ScreenUpdating = True
Set objFSO = Nothing
Set objFolder = Nothing
Set objFile = Nothing
End Sub
Bookmarks