Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print Multiple Worksheets (E2000)

    I have tried to adapt something that Hans advised on in <post#=305250>post 305250</post#> which told another user how to put an input box onto a button command but cannot get it to work with the activesheet.printout command. Basically I just want to 'pretty up' a form with a print button which when pressed asks for the number of copies which is then sent to the default printer.

    Any ideas please


    Thanks

    Stephen

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Print Multiple Worksheets (E2000)

    Something like this?

    sub PrintMultCopies
    Dim intCopies As Integer
    intCopies = Application.InputBox("Enter number of copies to print", "Print", 1, , , , 1)
    If intCopies < 1 Then Exit Sub
    Activesheet.PrintOut Copies:=intCopies
    End sub

    Steve

  3. #3
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    London, Gtr London, United Kingdom
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Multiple Worksheets (E2000)

    Thanks for the response Steve

    I have double clicked the button and put it what you suggested so that I end up with this

    Private Sub CommandButton1_Click()
    Sub PrintMultCopies()
    Dim intCopies As Integer
    intCopies = Application.InputBox("Enter number of copies to print", "Print", 1, , , , 1)
    If intCopies < 1 Then Exit Sub
    ActiveSheet.PrintOut Copies:=intCopies
    End Sub

    When I press the button it highlights the line Private Sub CommandButton1_Click()

    If I take this out I can click the buton without it putting up and error but it does not work, any other ideas?

    Cheers


    Stephen

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

    Re: Print Multiple Worksheets (E2000)

    You cannot have a sub within another sub:

    Private Sub CommandButton1_Click()
    Sub PrintMultCopies()

    Take out the second line, it should work ok then. Alternatively, you can keep

    Sub PrintMultCopies()
    Dim intCopies As Integer
    intCopies = Application.InputBox("Enter number of copies to print", "Print", 1, , , , 1)
    If intCopies < 1 Then Exit Sub
    ActiveSheet.PrintOut Copies:=intCopies
    End Sub

    and call it like this:

    Private Sub CommandButton1_Click()
    PrintMultcopies
    End Sub

Posting Permissions

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