ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing all Visible sheets (https://www.excelbanter.com/excel-programming/326436-printing-all-visible-sheets.html)

Darin Kramer

Printing all Visible sheets
 
Hi

I get an error message "Method 'PrintOut' of Object_'Worksheet' failed
when running the following Macro:

Sub PrintVisibleSheets_2()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Visible Then
If ws.Name < "Grading_guid" Then
ws.PrintOut Copies:=1, Collate:=True
End If
End If
Next
End Sub

I have turned protectin on on some of the sheets.
One sheet is Very Hidden
Line that it highlights to debug is ws.Printout line

The Macro used to work before!!!

(i even tried to delete the IFws.name line (not essential not to print
that one) - so question is how can I print all visible sheets in a
workbook??

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***

Bob Phillips[_6_]

Printing all Visible sheets
 
VeryHidden sheets evaluate to True in

If ws.Visible Then

Try

if ws.Visible = xlSheetVisible Then

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Darin Kramer" wrote in message
...
Hi

I get an error message "Method 'PrintOut' of Object_'Worksheet' failed
when running the following Macro:

Sub PrintVisibleSheets_2()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Visible Then
If ws.Name < "Grading_guid" Then
ws.PrintOut Copies:=1, Collate:=True
End If
End If
Next
End Sub

I have turned protectin on on some of the sheets.
One sheet is Very Hidden
Line that it highlights to debug is ws.Printout line

The Macro used to work before!!!

(i even tried to delete the IFws.name line (not essential not to print
that one) - so question is how can I print all visible sheets in a
workbook??

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***




Darin Kramer

Printing all Visible sheets
 

Brilliant!! It works Thanks


*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 12:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com