vbanoob1234
New Member
- Joined
- Aug 8, 2016
- Messages
- 26
Hello everyone,
This is my code. This code will grab all the files from a source folder, open each workbook, print all worksheets, and then close it. repeat.
However, I am getting an error saying "Run Time Error 1004. Method "PrintOut" of object_Worksheet. failed.
I think it is because there are very hidden and hidden sheets on the workbook.
Any help is appreciated. Thanks
Thank you
This is my code. This code will grab all the files from a source folder, open each workbook, print all worksheets, and then close it. repeat.
However, I am getting an error saying "Run Time Error 1004. Method "PrintOut" of object_Worksheet. failed.
I think it is because there are very hidden and hidden sheets on the workbook.
Any help is appreciated. Thanks
Rich (BB code):
Dim sFil As String, sPath As String
Set wb = ActiveWorkbook
Set ws = ActiveSheet
'change path to match yours
sPath = "C:\Desktop" 'location of files
sFil = Dir(sPath & "*.xlsx") 'change or add formats
Application.DisplayAlerts = False
Do Until sFil = ""
Workbooks.Open sPath & sFil
Set wb = ActiveWorkbook
'ws.PrintOut
For Each ws In wb.Worksheets
If Worksheet.Visible Then ws.PrintOut
Next
wb.Close
sFil = Dir()
Loop
Application.DisplayAlerts = True
End Sub
Thank you
Last edited by a moderator: