print preview not working

ira daboy

New Member
Joined
Oct 10, 2013
Messages
20
Office Version
  1. 365
Platform
  1. Windows
I am trying to build a button to print two specific sheets, "PS" and "PL" are the name of the worksheets. But before the print I would like to preivew and if the preview is not acceptable then stop executing code. what is happening in the code i have build, if i Xout of the print preview it goes ahead and print anyway. does anyone know how i can stop it from printing if the preview in not acceptable? Below is the code i have so far. thanx

VBA Code:
Private Sub CommandButton4_Click()
  Dim PrntRng As Range
Set PrntRng = Application.InputBox("Select Range To Print", "Select Range", Type:=8)
ActiveSheet.PageSetup.PrintArea = PrntRng.Address
Debug.Print PrntRng.Columns.Count
Debug.Print PrntRng.Rows.Count

Sheets(Array("PS", "PL")).PrintPreview
    Sheets(Array("PS", "PL")).PrintOut
    Sheets("PL").Select
End Sub
 
Last edited by a moderator:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You're welcome. Thanks for letting us know. :)
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,779
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top