OzGrid

How to Print hidden sheets without viewing the sheet being printed

< Back to Search results

 Category: [Excel]  Demo Available 

How to Print hidden sheets without viewing the sheet being printed

 

Requirement:

 

The user has  a command button running a code which prints sheets in a workbook. The sheets being printed are hidden, but as the code runs it shows the hidden sheet before it prints and the user does not want the hidden sheet shown. The user wants the sheet with the command button to remain in view the whole time. Ideally the user would also prefer not see the print dialogue box either.

 

Solution:

 

adding this code before and after you print:

Code:
Sub printout()
'
'
Dim rngtoprint
  With Application
    .ScreenUpdating = False
    .EnableEvents = False
  End With
  
  Set rngtoprint = Sheet9
  rngtoprint.printout Preview:=False
  Set rngtoprint = Sheet8
  rngtoprint.printout Preview:=False
  Set rngtoprint = Sheet6
  rngtoprint.printout Preview:=False
  Set rngtoprint = Sheet5
  rngtoprint.printout Preview:=False
  Set rngtoprint = Sheet4
  rngtoprint.printout Preview:=False
  Set rngtoprint = Sheet3
  rngtoprint.printout Preview:=False
  
  With Application
    .ScreenUpdating = True
    .EnableEvents = True
  End With
End Sub

This will stop the sheets being printed from being seen.

 

Obtained from the OzGrid Help Forum.

Solution provided by gijsmo.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

 

How to print userform in orientation landscape
How to print to specific network printer
How to use VBA code to print out an area
How to use VBA code to print number of copies based on cell value
How to create VBA code to increment number each time a copy is printed

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)