+ Reply to Thread
Results 1 to 3 of 3

Visual basic print code for excel 2007

Hybrid View

  1. #1
    Registered User
    Join Date
    07-29-2009
    Location
    Ireland
    MS-Off Ver
    Excel 365
    Posts
    54

    Visual basic print code for excel 2007

    Hi can someone help i have a workbook, which i use as an order form. i would like to have a print button on the workbook. is there a code i can enter to make this print to the default printer?

    Thanks


    Mattless1
    Attached Files Attached Files

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Visual basic print code for excel 2007

    Right-click the button, choose Assign Macro, New, and you'll see
    Sub Button1_Click()
    
    End Sub
    Then add this line:
    Sub Button1_Click()
        ActiveSheet.PrintOut
    End Sub
    Then you will need to save as a macro-enabled (.xlsm) workbook, close, and reopen.

    In the alternative, you could just add a print button to the quick-launch toolber.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Visual basic print code for excel 2007

    Hello mattless1.

    You can use
    sub mattless ()
    ActiveWindow.SelectedSheets.PrintOut Copies:=1 
    end sub
    And that should sent the print to the defult printer.

    Or you can chose the defult printer from a dialog box before the print.

    Sub mattless()
    Application.Dialogs(xlDialogPrinterSetup).Show
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    End Sub
    I have noticed that when your worksheet is printed it is printed over two pages.
    you can specify a print range "edit the red for your range"
    Range("A12", Range("A65536").End(xlUp).Offset(0, 9)).PrintOut Copies:=1, Collate:=True
    you may also be able to fit it on one page with changing the cell length.

    Good luck, and hope this helps.
    Last edited by D_Rennie; 08-09-2009 at 07:16 PM.

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