View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vasant Nanavati Vasant Nanavati is offline
external usenet poster
 
Posts: 1,080
Default 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/