VBA exit print preview back to sub routine

picklefactory

Well-known Member
Joined
Jan 28, 2005
Messages
508
Office Version
  1. 365
Platform
  1. Windows
Hi folks, hope someone can help please

I have a worksheet that I am print previewing from a user form but obviously when I print or just close the print preview it just leaves me on the sheet, but I'd like to exit back to the user form or even a different form, either would be good. Is it possible?
In case it helps, I've enclosed the simple bit of code I've used to generate the preview (Simple code is my limit I'm afraid)

Thanks

Code:
Private Sub cmdViewMachine_Click()

'Load selected machine to cell C2 in MachineSpec sheet
    ActiveWorkbook.Sheets("MachineSpec").Activate
    Range("B2").Select
    
    ActiveCell.Value = cboMachineName.Value
    
    Unload frmMachines
    ActiveWorkbook.Sheets("MachineSpec").Activate
    ActiveSheet.PageSetup.PrintArea = "$A$1:$I$36"
    ActiveSheet.PrintOut Preview:=True, ActivePrinter:="Xerox WorkCentre 7428-2 PCL6"



End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

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