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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
You're welcome. Thanks for letting us know. :)
 
Upvote 0

Forum statistics

Threads
1,215,406
Messages
6,124,720
Members
449,184
Latest member
COrmerod

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