+ Reply to Thread
Results 1 to 9 of 9

Thread: Printing different worksheets from multiple workbooks

  1. #1
    Registered User
    Join Date
    01-10-2007
    Posts
    4

    Printing different worksheets from multiple workbooks

    I have around 8 workbooks each with about 30 worksheets in them.

    Is there anyway i can create a new workbook with a sheet containing several buttons. When one of the buttons is pressed it will print out a number of specific sheets from the workbooks?

  2. #2
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003 & 2007
    Posts
    3,714

    Smile

    Good afternoon andycreighton

    Welcome to the forum!

    This sounds like just the kind of job that the macro recorder was built for. Go to Tools > Macro > Record new macro and go through the tasks you want to do - opening, selecting sheets, printing closing etc - then click on the stop recording button.

    Design a button using the Forms toolbar, right click the button and assign the macro you've just created to it.

    Good luck!

    HTH

    DominicB

  3. #3
    Registered User
    Join Date
    01-11-2007
    Posts
    1
    Is there any way you can print a sheet without haveing to unhide it??

    Cheers

    Andrew C

  4. #4
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003 & 2007
    Posts
    3,714

    Smile

    Good morning andrewbc

    No. But you can use a macro to unhide the sheet, print it and rehide it again. If you use the line :

    Application.ScreenUpdating=False
    at the start of your macro and set the flag back to true at the end, then the user will never see the sheet being unhidden.

    Why have you reregistered under a different name?

    HTH

    DominicB
    Last edited by dominicb; 01-11-2007 at 02:56 AM.

  5. #5
    Registered User
    Join Date
    01-10-2007
    Posts
    4
    I attempted recording a macro in a new work book to print them all but got Run-Time error 9; Subscript out of range.

    Also when i looked at the VBA the code read....

    ActiveWindow.ScrollWorkbookTabs Sheets:=7
    Sheets("GRAYSTONE").Select

    Im assuming that means the workbook has to physically be open to work. Is there anyway to do it without having to open them beforehand?

    Thanks

    Andy

  6. #6
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003 & 2007
    Posts
    3,714

    Smile

    Hi andycreighton

    No, you have to open the workbook to print it. However, you can hide the opening of a spreadhseet from the user by using the Application.ScreenUpdating command. The macro below has been part recorded by my, and I then added manually the first and last line which will stop the user from seeing the file open and close. All they will experience is a slight delay.

    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 11/01/2007 by Dominic Brown1
    '
    
    '
    Application.ScreenUpdating = False
        Workbooks.Open Filename:="D:\Work\Analysis-Output.xls"
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
        ActiveWindow.Close
    Application.ScreenUpdating = True
    End Sub
    HTH

    DominicB

  7. #7
    Registered User
    Join Date
    01-10-2007
    Posts
    4
    Cheers that works like a charm.

    Is there anyway I can print more than 1 sheet? also is there anyway i can choose which sheets to print?

    Thanks again

    Andy

    EDIT: btw andrewbc is not me lol
    Last edited by andycreighton; 01-11-2007 at 06:48 AM.

  8. #8
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003 & 2007
    Posts
    3,714

    Smile

    Hi andycreighton

    Is there anyway I can print more than 1 sheet?
    Sure - just use the macro recorder and print more than one sheet before closing the file and turning off the recorder.

    also is there anyway i can choose which sheets to print?
    Phew! Now you're getting into the heavy stuff - you would need to read the sheetnames of the new sheet into an object for the user to see, read what the user has selected and act accordingly - all without ever showing the user the sheet they've selected. Not the type of stuff you can achieve with the recorder. Have a look at this little spreadsheet I've put together - should do the trick for you...

    HTH

    DominicB
    Last edited by dominicb; 08-19-2008 at 04:29 AM.

  9. #9
    Registered User
    Join Date
    01-10-2007
    Posts
    4
    Wow thats class lol cheers.

    Your gonna hate me, but I have one more question. The sheets I will be printing off each week will be the same everytime. Is there anyway I could bring up a list of predefined customers lol say for example.

    There were 10 customers, each with thier own seperate invoice.

    Shop 1
    Shop 2
    Shop 3
    Shop 4
    Shop 5
    Shop 6
    Shop 7
    Shop 8
    Shop 9
    Shop 10

    But I only wanted to print off invoices from shop 1, 4, 8 and 10. This will be the same every week and will not change. I dont want the user to have to manually select the sheets to print off. Is it possible?
    Last edited by andycreighton; 01-11-2007 at 07:30 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0