Printing problem

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
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 :
 
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.
 
Back
Top