LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Assigned macro in Dialog giving error

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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Giving me a error ( =REF! ) Steved Excel Worksheet Functions 2 October 5th 09 01:10 AM
Error using a combo box with an assigned macro in Excel EA Excel Worksheet Functions 2 October 2nd 07 04:08 PM
Error using a combo box with an assigned macro in Excel EA Excel Discussion (Misc queries) 0 October 1st 07 08:18 PM
Macro giving runtime error on one PC and not another Ingrid Excel Programming 2 September 13th 05 07:41 PM
Macro giving runtime error on one PC and not another Jim Thomlinson[_4_] Excel Programming 0 September 13th 05 05:45 PM


All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"