Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tick box to print worksheets (2k)

    Hi,
    I have the following code on a command button in excel:

    Private Sub CommandButton1_Click()
    If Me.CheckBox1 = True Then
    Worksheets("AD Sheet - Defence").PrintObject = True
    End If
    If Me.CheckBox7 = True Then
    Worksheets("AD Sheet - Defence Evidential").PrintObject = True
    End If
    If Me.CheckBox6 = True Then
    Worksheets("AD Sheet - Courts").PrintObject = True
    End If
    If Me.CheckBox5 = True Then
    Worksheets("AD Sheet -Court Evidential").PrintObject = True
    End If
    If Me.CheckBox4 = True Then
    Worksheets("PSR Package").PrintObject = True
    End If
    If Me.CheckBox3 = True Then
    Worksheets("PSR Package - Evidential").PrintObject = True
    End If
    End Sub

    But it doesn't work.
    Basically I need to print of whole work sheets based on the value of CheckBoxes. So for instance if Checkbox4 is ticked, the user hits print (CommandButton1) and just that sheet is printed. Likewise if mulitple sheets are selected.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Tick box to print worksheets (2k)

    Instead of x.PrintObject = True use x.Printout

  3. #3
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tick box to print worksheets (2k)

    Cheers Hans.
    I now get the Runtime Error "1004"
    Unable to set the Printout property of the worksheet class.

    The sheet prints, so what does this mean??

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Tick box to print worksheets (2k)

    Are you using something like

    Worksheets("AD Sheet - Defence").PrintOut = True

    That isn't correct, it should be

    Worksheets("AD Sheet - Defence").PrintOut

    as indicated in my previous reply.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tick box to print worksheets (2k)

    Indeed that was the case. <img src=/S/doh.gif border=0 alt=doh width=15 height=15>
    Many thank as always.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •