• VBA to change printer properties

    Author
    Topic
    #357176

    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.

    Viewing 1 reply thread
    Author
    Replies
    • #530399

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

      • #530432

        From the API-Guide for the Windows API call to PrintDialog:
        Edited by Charlotte to stop horizontal scrolling

        '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
        
        

        Notice the PrintQuality property. There may be some hope for you there. Check out the API. It may be your only possibility.

    • #530518

      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.

    Viewing 1 reply thread
    Reply To: VBA to change printer properties

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: