+ Reply to Thread
Results 1 to 3 of 3

print macro with selected options

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2021
    Posts
    979

    Re: print macro with selected options

    hi,

    thanks for the reply
    got your idea to record macro, below works

    cant find also 8.5 x 13 paper size so i just chose legal size

    Sub PDFPRINTER()
    '
    ' Macro1 Macro
    '
    
    '
    Dim prntr As String
    
        prntr = FindPrinter("Microsoft Print to PDF")
        Application.ActivePrinter = prntr
    
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
        End With
        Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = ""
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
             .Orientation = xlLandscape
            .PaperSize = xlPaperLegal
        End With
        Application.PrintCommunication = True
        ActiveWindow.SelectedSheets.PrintOut From:=1, To:=10, Copies:=1, Collate _
            :=True, IgnorePrintAreas:=False
    End Sub
            
            
    Public Function FindPrinter(ByVal PrinterName As String) As String
      Dim Arr As Variant
      Dim Device As Variant
      Dim Devices As Variant
      Dim Printer As String
      Dim RegObj As Object
      Dim RegValue As String
      Const HKEY_CURRENT_USER = &H80000001
           
        Set RegObj = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
        RegObj.enumvalues HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Devices", Devices, Arr
        
          For Each Device In Devices
            RegObj.getstringvalue HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Devices", Device, RegValue
            Printer = Device & " on " & Split(RegValue, ",")(1)
            If InStr(1, Printer, PrinterName, vbTextCompare) > 0 Then
               FindPrinter = Printer
               Exit Function
            End If
          Next
    
    End Function
    Last edited by k1dr0ck; 09-28-2018 at 04:29 AM.

+ 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. [SOLVED] Macro to Print All Options in a Drop Down List
    By lianne.cuscani in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-25-2018, 01:51 PM
  2. [SOLVED] Macro to Print All Options in a Drop Down List
    By Kennylj24 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-15-2016, 11:55 AM
  3. Macro print all options of Combo Box
    By julien_hh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2015, 06:00 AM
  4. Replies: 0
    Last Post: 11-14-2014, 08:56 AM
  5. Macro for Multiple Print Options
    By jaredmccullough in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2014, 07:23 AM
  6. View /Print selected options contiguously separate page
    By t_track in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-25-2008, 07:26 PM
  7. save as and print options macro
    By ramblin racer in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-01-2007, 03:48 AM

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