PDA

View Full Version : Solved: Print Preview



pico
11-07-2006, 12:43 PM
How would i show the preview screen from a macro. Iam talking about the excel preview screen. If the user selects print on the macro it would invoke the print preview screen with the specific sheet . The reason i want to do this is to let the user get only printing privileges.I do not want the user to edit any data from that sheet. Just a readonly for printing purposes. Thanks.

mdmackillop
11-07-2006, 01:10 PM
Hi Pico,
Try using the macro recorder for this. I'm not clear what more you need.
Regards
MD

Bob Phillips
11-07-2006, 01:49 PM
Why not just protect the worksheet?

pico
11-07-2006, 02:25 PM
I'd like the user to preview the form and print from there. I have included the print button on my form. When the user clicks this button i would like the macro to invoke the print preview screen and print the specific sheet. The print function in my macro pretty much is used to generate reports to be printed.

Zack Barresse
11-07-2006, 02:38 PM
The VBA method for showing the Print Preview is...

ActiveWindow.SelectedSheets.PrintPreview

pico
11-07-2006, 02:40 PM
FireFyter...thank you..Exactly what i needed.:beerchug:

Zack Barresse
11-07-2006, 02:43 PM
Glad it works for you!

Don't forget to mark your thread as Solved. :yes

pico
11-07-2006, 02:51 PM
Sorry i think i hit the solved button a little to early there. When i show print preview screen the form that i invoke it from hangs and stays on the foreground. I do see the print preview screen hidden behind the form. How can i get the print preview screen on top of my macro form screen?

Zack Barresse
11-09-2006, 05:35 PM
What form? A userform? Unload it. If you want it in memory still, use the Hide method (i.e. Userform1.Hide).

lucas
11-09-2006, 09:53 PM
You also need to hide the form first...then do the preview:

Private Sub CommandButton1_Click()
UserForm1.Hide
ActiveWindow.SelectedSheets.PrintPreview
End Sub

pico
11-20-2006, 07:01 AM
The hide method works, but when the user is done with the print screen i'd like ther userform to be seen again. Can i use the top property to push my userform behind the print preview screen somehow?, So when the user is done with the print preview screen the userform is still visible.?

lucas
11-20-2006, 07:35 AM
Try this pico:

Private Sub CommandButton1_Click()
UserForm1.Hide
ActiveWindow.SelectedSheets.PrintPreview
UserForm1.Show
End Sub

pico
11-20-2006, 07:40 AM
Yahooooo....thanks....can finally say it works the way i want it to work. Cheers:beerchug:

lucas
11-20-2006, 07:47 AM
Glad it's working......it's pretty satisfying when things work out right.