+ Reply to Thread
Results 1 to 9 of 9

Print Workbook Macro

  1. #1
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Print Workbook Macro

    Hello,

    I'm creating a macro that will set the print areas on my workbook automatically and open up the print dialog box. I've attached a copy of the spreadsheet that I'm working on.

    I only want to print the yellow area in Sheet1, Sheet2 and Sheet3. I don't want to print Sheet 4.

    I've created a copy of the macro that I'm working on. Any help on how I can get it to work would be appreciated.

    Please Login or Register  to view this content.
    Thanks

    PrintWorkbook.xlsx

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Print Workbook Macro

    In each section, add a command to print that sheet, for instance:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Print Workbook Macro

    Hi,

    See if this is what you are after...click the button on Sheet1.

    Hope this helps
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Print Workbook Macro

    @JBeaucaire: I didn't think that displayed the dialog...?

    The method I used selects all the sheets required as an array after the page setup macros, then autoselects the "Selection" option under "Print What", so that only the selected worksheets are printed

  5. #5
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Re: Print Workbook Macro

    Quote Originally Posted by ajryan88 View Post
    @JBeaucaire: I didn't think that displayed the dialog...?

    The method I used selects all the sheets required as an array after the page setup macros, then autoselects the "Selection" option under "Print What", so that only the selected worksheets are printed
    Thank you so much ajryan88.

    The only problem I'm having is that it only prints the selected cells A1 in Sheet1, Sheet2 and Sheet3.

    If I change my preference to "Entire Workbook" in the Print Dialog box, it then prints all the Sheets (I don't want to print Sheet4).

  6. #6
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Print Workbook Macro

    Sorry, my mistake. In my code, remove the Arg12:=True. This should then select Active Sheet(s) by default.

    Hopefully this works for you
    Last edited by ajryan88; 08-17-2013 at 10:59 PM.

  7. #7
    Registered User
    Join Date
    02-21-2013
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Re: Print Workbook Macro

    Quote Originally Posted by ajryan88 View Post
    Sorry, my mistake. In my code, remove the Arg12:=True. This should then select Active Sheet(s) by default.

    Hopefully this works for you
    Thanks ajryan88. That did the trick.

  8. #8
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Print Workbook Macro

    Glad to hear it!

    Have a great day

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Print Workbook Macro

    You're correct, my method did not present any print dialog windows. IF you add this to the bottom, it would simply print those 3 sheets with no prompts:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro Applying Print Fit to One Page on All Worksheets in Workbook
    By brokbird in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-24-2013, 09:13 PM
  2. [SOLVED] Add a macro to a button to print whole workbook
    By jetlee in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-22-2013, 11:26 AM
  3. Printing Macro, set workbook to only print certain sheets
    By AMFISH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2012, 04:37 PM
  4. How to have a macro print output to individual tabs in a new workbook?
    By RG Series in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2012, 10:34 AM
  5. Replies: 1
    Last Post: 10-27-2005, 06:00 PM

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.6.0 RC 1