Printing problem

G

Guest

Hi
I have six sheets in my workbook. On my userform I have a checkBox for each
sheet and a button to start the printing. The user selects which sheets to
print by selecting the checkBoxes. When I try to print though it tells me
"Run-time error '1004':
Method 'PrintPreview' of object '_Worksheet' failed"

Below is a sample of the code i am using

Private Sub CommandButton1_Click()
Windows("Data.xls").Activate
If CheckBox1.Value Then
Sheet1.PrintPreview
'ActiveSheet.PrintOut
End If
End Sub


All help wil be greatly appreciated.
 
G

Guest

sheet1 needs to be the active sheet

Private Sub CommandButton1_Click()
Sheet1.Activate
If CheckBox1.Value Then
Sheet1.PrintPreview
'ActiveSheet.PrintOut
End If
End Sub
 
K

keepITcool

calling printpreview with an open userform
will hang excel unless the form is hidden first.

Private Sub CommandButton1_Click()
Me.Hide
ActiveSheet.PrintPreview
Me.Show
End Sub

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Patrick Molloy wrote :
 
G

Guest

Hi
Still not working for me. It works fine when I place the code in the
Worksheet itself, but not when it is in the userform. As if a sheet object is
not created.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

How to activate Sheet2? 5
Printing 1
Email selected sheets 5
Select Sheets to Print 11
paste to word 7
Hidden sheet bleeds through 3
Userform Can't seem to work right 3
Print selected sheets in Excel 6

Top