Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Mar 2002
    Location
    Tampa, Florida, USA
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA to change printer properties

    Can I use a VBA macro (Word 2000) to change printer settings, i.e., change print quality? If so, how?

    It is an awful nuisance for the user to have go through the steps necessary to chance settings. There ought to be a faster way.

    Thanks.

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    JustCallMeAl
    Guest

    Re: VBA to change printer properties

    We just tried to do something similar. I am sharing what I found out about printers and VB/VBA.

    There are two levels of printer properties--one is the properties you can change when you select Start, Settings, Printers, select the particular printer, Properties. Those are NOT accessable via VB/VBA. (At least that was our experience. And, yes, this also includes via API calls.)

    The other properties are the properties that you see when in Word you select File, Print Setup, Options. Some of those are accessable via VB/VBA, some are not. The ones that are accessable can be found as a property of the Options object.

    Specifically, can you change the print quality? I doubt it. Unless SendKeys will work.

  4. #3
    Lounger
    Join Date
    Mar 2002
    Location
    Tampa, Florida, USA
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA to change printer properties

    Thanks; I saw your question related to this issue a while back. I was hoping that someone might have found a way around this.

  5. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA to change printer properties

    From the API-Guide for the Windows API call to PrintDialog:
    Edited by Charlotte to stop horizontal scrolling
    <pre>'Call the print dialog up and let the user make changes
    If PrintDialog(PrintDlg) <> 0 Then

    'First get the DevName structure.
    lpDevName = GlobalLock(PrintDlg.hDevNames)
    CopyMemory DevName, ByVal lpDevName, 45
    bReturn = GlobalUnlock(lpDevName)
    GlobalFree PrintDlg.hDevNames

    'Next get the DevMode structure and set the printer
    'properties appropriately
    lpDevMode = GlobalLock(PrintDlg.hDevMode)
    CopyMemory DevMode, ByVal lpDevMode, Len(DevMode)
    bReturn = GlobalUnlock(PrintDlg.hDevMode)
    GlobalFree PrintDlg.hDevMode
    NewPrinterName = UCase$(Left(DevMode.dmDeviceName, _
    InStr(DevMode.dmDeviceName, Chr$(0)) - 1))
    If Printer.DeviceName <> NewPrinterName Then
    For Each objPrinter In Printers
    If UCase$(objPrinter.DeviceName) = NewPrinterName Then
    Set Printer = objPrinter
    'set printer toolbar name at this point
    End If
    Next
    End If

    On Error Resume Next
    'Set printer object properties according to selections made
    'by user
    Printer.Copies = DevMode.dmCopies
    Printer.Duplex = DevMode.dmDuplex
    Printer.Orientation = DevMode.dmOrientation
    Printer.PaperSize = DevMode.dmPaperSize
    Printer.PrintQuality = DevMode.dmPrintQuality
    Printer.ColorMode = DevMode.dmColor
    Printer.PaperBin = DevMode.dmDefaultSource
    On Error GoTo 0
    End If

    </pre>


    Notice the PrintQuality property. There may be some hope for you there. Check out the API. It may be your only possibility.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #5
    JustCallMeAl
    Guest

    Re: VBA to change printer properties

    When in Word 97 and you select a printer, then options, on the printers I have worked with, the printer quality can be changed there. So, that is one that can be changed.

    However, from my previous thread, there are many properties/options not available to VB/VBA.

  7. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA to change printer properties

    Al,

    >>However, from my previous thread, there are many properties/options not available to VB/VBA.

    And my guess as to why this is so: printer property sheets reflect the features available for each printer. Each new printer has new features that Windows could never account for unless...

    ...unless the Windows API could hook into the actual printer driver and you, the programmer, had access to that specific printer driver objects.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #7
    JustCallMeAl
    Guest

    Re: VBA to change printer properties

    That was my conclusion, too. The properties that MS could be pretty sure of existing for all printers, they made available to VB/VBA. Those not, they didn't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •