+ Reply to Thread
Results 1 to 2 of 2

Print selected worksheet to a specific printer or save as pdf

Hybrid View

  1. #1
    Registered User
    Join Date
    02-04-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    23

    Print selected worksheet to a specific printer or save as pdf

    Hi

    i want my code to print named pages but allow me to select a printer from the printer list if it isn't possible i want the code to save those worksheet as pdf in file, can someone help?

    Sub PrintNamedWorksheets()
    
        Dim ws As Worksheet
        Dim printArea As String
    
        sheetNames = "Title Page,Summary"
        printArea = "A1:j42,B1:i141" 'Adjust to match the print area you want
    
        For Each sheetName In Split(sheetNames, ",")
            Set ws = ThisWorkbook.Worksheets(sheetName)
            ws.PageSetup.printArea = printArea
            
            ' Only print worksheets with specific names
            If ws.Name = "Title Page" Or ws.Name = "Summary" Then
                ' Set print settings to fit all columns on one page
                With ws.PageSetup
                    .Zoom = False
                    .FitToPagesWide = 1
                    .FitToPagesTall = False
                End With
                ' Print the current worksheet
                ws.PrintOut ActivePrinter:=True
            End If
        Next ws
    
    End Sub

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,259

    Re: Print selected worksheet to a specific printer or save as pdf

      If Application.Dialogs(xlDialogPrinterSetup).Show Then
        'user selected a printer and pressed the [OK] button.
        Stop
      Else
        'user pressed the [Cancel] button
        Stop
      End If
    Artik

+ 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. Print each sheet to PDF Printer NOT Using Save as PDF Function
    By esposit513 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2018, 05:23 PM
  2. Replies: 1
    Last Post: 06-30-2017, 10:29 AM
  3. [SOLVED] Print from Userform with Selected Printer
    By indub in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-18-2017, 11:05 AM
  4. Print worksheet based on cell value to specific printer
    By swiftrain in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2013, 09:57 AM
  5. print on pdf printer - adjust filename & save
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-30-2011, 02:30 PM
  6. Print to a specific printer
    By Rodeoclown in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2010, 05:22 PM
  7. [SOLVED] How to save settings for my printer to print doublesided from exce
    By Tess76 in forum Excel General
    Replies: 0
    Last Post: 05-25-2005, 11:06 AM

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