+ Reply to Thread
Results 1 to 17 of 17

Selected print page macro

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Selected print page macro

    Hi
    Is there a macro vba code for a selected page to print only? Let say I have a button in the worksheet that when I click that button, will ask what page I want to print and then how many pages.

    Let say if I want to print just page 2 and it will ask me how many pages I want to print.

    Thanks.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Selected print page macro

    When you say "page", I assume you mean the 2nd range of the large print range. Not the 2nd sheet in a workbook.
    "what page I want to print" is singular and "how many pages" is plural. Do you mean "How many copies" of that particular page?

  3. #3
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Selected print page macro

    Sorry, my English not that good. I have a workbook and have multiple sheets.
    I have several pages in the each worksheet and let say Sheet2. In worksheet Sheet2 I Just want to print Page 3 and I want a message box that will say "how many copies you want to print" then click "OK".

    Something like this.

    thanks.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Selected print page macro

    Is this what you mean?
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Selected print page macro

    Hi
    Wow.... yes. this is exactly how I want to accomplish.
    But is there a way you can indicate what worksheet since I have a lot of worksheet in a workbook. Let say Sheet2.

    Thank you

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Selected print page macro

    You'll have to enter the sheet name (WITHOUT SPELLING MISTAKES) in the InputBox.
    Please Login or Register  to view this content.
    You'll have to enter the sheet index number in the InputBox.
    Index number is the sheet number, looking down at the tabs, starting with 1 for the left sheet.
    Please Login or Register  to view this content.
    Your next best option would be a UserForm where you would be able to select.

  7. #7
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Selected print page macro

    Hi
    I think I will stick with the Range A for now :o)

    I noticed when I reached to the message box "how many copies to print" and I click "cancel", then the error time appear '1004' and it said "The number must be between 1 and 32767. Try again by entering the number in this range.

    Is there anyway I can click "cancel" without getting the error?

    Thanks

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Selected print page macro

    Just before the amt line, put
    Please Login or Register  to view this content.
    and insert
    Please Login or Register  to view this content.
    just before the "End Sub" line

  9. #9
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Selected print page macro

    Perfect! Thank you Jolivanes.

    I do really appreciated.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Selected print page macro

    Have something to play with. (See attached)
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Selected print page macro

    good morning jolivanes :o)
    This is nice. I'll keep this for the future reference maybe on the next project i'll do. You're a genious!


    I don't know it is possible to add a "PRINT VIEW" (see below code - I added the code you want me to add) after you enter what sheet needs to be printed before the message box will come how many copies.

    If its not possible, then it will not be a problem because what I have is actually perfect. I just thought of it that maybe I wanted to see the print view before typing in how many copies I want to print.

    thank you my friend :o)

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Selected print page macro

    Try
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Selected print page macro

    Hi
    Yay! This is amazing :o)

    Is it okey, if I ask one more. I should I asked you in the beginning.
    The reason is I normally print a few pages the first time with color print and the second time which I print more pages with a regular black and white. So, Is there a way to after the probably after closing the "print Preview" then it goes directly to the image option from the printer properties?

    If not, no worry my friend.

    Thank you.

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Selected print page macro

    You have close to 800 Posts.
    What have you tried yourself?

    Please Login or Register  to view this content.
    Last edited by jolivanes; 07-10-2020 at 01:40 PM.

  15. #15
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Selected print page macro

    Hi,
    Question?
    Under the message box "which page number to be printed", how do I enter to print page 1 and page 4? Do I entered it like this, 1, 4

    I tried and it did not print page 1 and 4.

  16. #16
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Selected print page macro

    If you read your own Post #3 again you'll see that your moving the goalposts every Post after that.
    Maybe start another thread outlining what you have and what you want to achieve.
    Next time, before you post, think things through so we don't need to start over at every post.

  17. #17
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Selected print page macro

    Hi
    Ok... I did not know that. I will start a new thread.

    Thank you for all your help.

+ 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. Page setup when selected items are sent to print Preview
    By MikeGozna in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2020, 03:55 AM
  2. print only page 1 of selected sheets
    By bogey69 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-17-2018, 10:49 AM
  3. With excel to print a selected page from a word document
    By eb4927 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-15-2014, 05:54 PM
  4. [SOLVED] To print the selected range with page setup
    By muralidaran in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2014, 10:38 AM
  5. [SOLVED] Print Pivottable - show all selected items in page filter
    By Koen in forum Excel General
    Replies: 0
    Last Post: 06-19-2006, 04:35 AM
  6. [SOLVED] How do you print selected columns on one page?
    By Roadhand in forum Excel General
    Replies: 4
    Last Post: 09-14-2005, 07:05 AM
  7. [SOLVED] print selected sections on the same page
    By ripley in forum Excel General
    Replies: 1
    Last Post: 02-22-2005, 12:06 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