S
SJW_OST
Hello,
I have a Dialog box which contains 3 Check Boxes & 2 Buttons. I am using
this code to bring up the Dialog.
Sub Dialog()
'
DialogSheets("Dialog1").Show
End Sub
The 3 Check Boxes place a TRUE or FALSE in specific cells depending on if
the box is checked and the 2 Buttons are PRINT & Cancel. I have assigned this
code to the PRINT button.
Sub PRNT()
'
Sheets("Sheet2").Select
If Range("A1") = True Then
MyString = Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else: Sheets("Sheet2").Select
Range("A1").Select
End If
If Range("A2") = True Then
MyString = Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else: Sheets("Sheet2").Select
Range("A1").Select
End If
If Range("A3") = True Then
MyString = Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else: Sheets("Sheet2").Select
Range("A1").Select
End If
MsgBox "All checked boxes have been printed."
End Sub
The problem comes when any of the Check Boxes is checked and the above macro
is activated by clicking PRINT in the Dialog. I get;
Method 'PrintOut' of object 'Sheets' failed
I've looked at all of the attributes I know of, which is admittedly few, and
tried finding a solution via MS Help to no avail. Can some one help me with
this? I want to be able to print only the selected sheets based on which
Check Box has a check in it by clicking my PRINT Button in my Dialog.
Thank you for your help.
I have a Dialog box which contains 3 Check Boxes & 2 Buttons. I am using
this code to bring up the Dialog.
Sub Dialog()
'
DialogSheets("Dialog1").Show
End Sub
The 3 Check Boxes place a TRUE or FALSE in specific cells depending on if
the box is checked and the 2 Buttons are PRINT & Cancel. I have assigned this
code to the PRINT button.
Sub PRNT()
'
Sheets("Sheet2").Select
If Range("A1") = True Then
MyString = Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else: Sheets("Sheet2").Select
Range("A1").Select
End If
If Range("A2") = True Then
MyString = Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else: Sheets("Sheet2").Select
Range("A1").Select
End If
If Range("A3") = True Then
MyString = Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Else: Sheets("Sheet2").Select
Range("A1").Select
End If
MsgBox "All checked boxes have been printed."
End Sub
The problem comes when any of the Check Boxes is checked and the above macro
is activated by clicking PRINT in the Dialog. I get;
Method 'PrintOut' of object 'Sheets' failed
I've looked at all of the attributes I know of, which is admittedly few, and
tried finding a solution via MS Help to no avail. Can some one help me with
this? I want to be able to print only the selected sheets based on which
Check Box has a check in it by clicking my PRINT Button in my Dialog.
Thank you for your help.