Results 1 to 5 of 5

VBA to Print to Printer that is not default

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-24-2014
    MS-Off Ver
    Microsoft Office 2013
    Posts
    113

    VBA to Print to Printer that is not default

    I have a spreadsheet where I am trying to print barcode labels. The barcode is found in cell A1. I have looked in a lot of places and I can't really figure out exactly how to do it. This is the code that I have so far but it gives me an error. The printer name should be right. Any suggestions on how to fix it? Some of this code I just copied from another thread.
    Private Sub CommandButton1_Click() 'Print out labels in range A1
    Dim myprinter As String
    Dim printer_name As String
    printer_name = "DYMO LabelWriter 450 on Ne07"
    
        myprinter = Application.ActivePrinter
        Change_Form.PrintOut Preview:=False, ActivePrinter:=printer_name, PrintToFile:=True, PrToFileName:=PSFileName
            ActiveSheet.PageSetup.PrintArea = ""
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
            .LeftMargin = Application.InchesToPoints(0)
            .RightMargin = Application.InchesToPoints(0)
            .TopMargin = Application.InchesToPoints(0)
            .BottomMargin = Application.InchesToPoints(0)
            .HeaderMargin = Application.InchesToPoints(0)
            .FooterMargin = Application.InchesToPoints(0)
            .PrintHeadings = False
            .PrintGridlines = False
            .PrintComments = xlPrintNoComments
            .PrintQuality = 300
            .CenterHorizontally = True
            .CenterVertically = True
            .Orientation = xlLandscape
            .Draft = False
            .PaperSize = 160
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            .Zoom = 100
            .PrintErrors = xlPrintErrorsDisplayed
            .OddAndEvenPagesHeaderFooter = False
            .DifferentFirstPageHeaderFooter = False
            .ScaleWithDocHeaderFooter = True
            .AlignMarginsHeaderFooter = True
            .EvenPage.LeftHeader.Text = ""
            .EvenPage.CenterHeader.Text = ""
            .EvenPage.RightHeader.Text = ""
            .EvenPage.LeftFooter.Text = ""
            .EvenPage.CenterFooter.Text = ""
            .EvenPage.RightFooter.Text = ""
            .FirstPage.LeftHeader.Text = ""
            .FirstPage.CenterHeader.Text = ""
            .FirstPage.RightHeader.Text = ""
            .FirstPage.LeftFooter.Text = ""
            .FirstPage.CenterFooter.Text = ""
            .FirstPage.RightFooter.Text = ""
        End With
        Application.PrintCommunication = True
        Sheets("Label Printer").Range("A1").PrintOut Copies:=1, Collate:=True
        Application.ActivePrinter = myprinter
    End Sub
    Last edited by manofcheese; 06-05-2014 at 10:03 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. print to a user's default printer?
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2016, 12:28 PM
  2. [SOLVED] Macro to print to the default printer
    By Alves76 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-22-2013, 05:47 AM
  3. macro to print 2 copies to default printer, then 1 copy to Adobe PDF printer
    By jwright650 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-26-2011, 01:07 PM
  4. macro print to default printer help
    By st24rsap in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2009, 07:22 AM
  5. print to file instead of default printer
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2008, 12:57 PM

Tags for this Thread

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