Printing displayed sheets
After working with the user to limit the number of sheets displayed in a workbook (that includes 97 sheets) I would like to offer them the ability to print those sheets that are visible. Here is the code I have. It does select the sheets but I cannot print them. I have tried the printout syntax a million different ways but can't seem to get it to work. Sub Print_ActiveSheets_Macro() Sheets("Control").Select Dim ws As Worksheet For Each ws In Worksheets If ws.Visible Then ws.Select False Next ws msg = "You are printing the sheets selected below. " & vbCrLf msg = msg & "Do you want to continue?" response = MsgBox(msg, vbOKCancel + vbQuestion, "Print Alert") If response = vbOK Then ws.PrintOut ' For Each Worksheet In ws End Sub Thanks for your help --- ~~ Message posted from http://www.ExcelForum.com/ |
Printing displayed sheets
Keep it simple:
Sub Print_ActiveSheets_Macro() If MsgBox("You are printing all the visible sheets. " & vbCrLf _ & "Do you want to continue?", vbYesNo) = vbYes Then _ ActiveWorkbook.PrintOut End Sub -- Vasant "rduke0" wrote in message ... After working with the user to limit the number of sheets displayed in a workbook (that includes 97 sheets) I would like to offer them the ability to print those sheets that are visible. Here is the code I have. It does select the sheets but I cannot print them. I have tried the printout syntax a million different ways but can't seem to get it to work. Sub Print_ActiveSheets_Macro() Sheets("Control").Select Dim ws As Worksheet For Each ws In Worksheets If ws.Visible Then ws.Select False Next ws msg = "You are printing the sheets selected below. " & vbCrLf msg = msg & "Do you want to continue?" response = MsgBox(msg, vbOKCancel + vbQuestion, "Print Alert") If response = vbOK Then ws.PrintOut ' For Each Worksheet In ws End Sub Thanks for your help --- ~~ Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 05:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com