Printing problem

K

Kobus

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.
 
P

Patrick Molloy

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 :
 
K

Kobus

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
PrintPreview in I.E. ??? 2
Printing 1
Arrays and Checkboxes 3
Email selected sheets 5
Hidden sheet bleeds through 3
Not a 2nd print from the preview 0
paste to word 7

Top