Results 1 to 4 of 4
  1. #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. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 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

  3. #3
    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

  4. #4
    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
  •