Results 1 to 4 of 4
  • Thread Tools
  1. New Lounger
    Join Date
    Mar 2008
    Location
    Asheville, North Carolina, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA or Macro code to print (Excel 2007)

    I am working on an excel workbook. I want to and a command button to the first sheet so that it will print 2 copies of that sheet. Where can i find some VBA code to help me out. Thank you.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 13 Times in 13 Posts

    Re: VBA or Macro code to print (Excel 2007)

    Welcome to Woody's Lounge!

    You can often get a good idea of the code you need by recording a macro of the action(s) that you want to automate.

    - Make sure that you show the Developer tab in the Ribbon.
    - In the Code group, click Record Macro
    - Specify a name, for example Print2Copies, then click OK.
    - Perform the actions that you want to record.
    - Click the Stop Recording button when you're done.
    - Click Macros
    - Select the name that you gave the macro.
    - Click Edit. You'll see the code of the recorded macro.
    - The line that prints two copies in the macro that I recorded is:

    ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True

    - Click in the word PrintOut and press F1 to get help about this keyword.

    Note: an alternative instruction is

    ActiveSheet.PrintOut Copies:=2

  4. 5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA or Macro code to print (Excel 2007)

    Welcome to the lounge!

    The simplest way to do this is to record a macro of the normal printing procedure. You can then assign that macro to the button.

    It will look something like this:

    Application.ActivePrinter = "YourPrinter'sName"
    ActiveWindow.SelectedSheets.PrintOut Copies:=2, ActivePrinter:= _
    "YourPrinter'sName", Collate:=True

  5. New Lounger
    Join Date
    Mar 2008
    Location
    Asheville, North Carolina, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA or Macro code to print (Excel 2007)

    Thank you for the help. It has been some time since i have used VBA codes. This should get my project completed. Thank you.

Posting Permissions

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