Print macro using xlDialogPrinterSetup fails to use driver-specific settings

Joined
Feb 2, 2012
Messages
1
Reaction score
0
I have a piece of VBA code that prints a set of sheets if certain criteria on another sheet containing the code and the control button are met.

Code:
Sub Printer()
        Dim rnSheets As Range
        Dim rnSheetName As Range
        Dim myCell As Range
        Dim sNameAdress As String
        Dim fName As String
        Dim ws As Worksheet
        sNameAdress = "I10"
        Set rnSheets = Me.Range("c12:c39")
        Application.ScreenUpdating = False
        On Error Resume Next
        'denna rad ger ett fel om skrivaren inte finns, därav inneslutning av felhanterare.
        'kanske felet bör hanteras?
        Application.ActivePrinter = "GOTATUNNELN-04 på Ne02:"
        On Error GoTo 0
        'tar upp skrivardialog.
        Application.Dialogs(xlDialogPrinterSetup).Show
        'Application.Dialogs(xlDialogPrint).Show
        For Each myCell In rnSheets
                If myCell <> "" Then
                Set rnSheetName = myCell.Offset(0, -2)
                On Error Resume Next
                Set ws = Worksheets(rnSheetName.Text)
                On Error GoTo 0
                If ws Is Nothing Then
                        MsgBox "Kan ej hitta arbetsblad med namn " & rnSheetName, vbExclamation, "Fel!"
                Else
                        With ws
                        'med en skillnad.
                        .PrintOut
                        'alternativt, bara för att vara säker...
                        '.PrintOut ActivePrinter:="GOTATUNNELN-04 på Ne02:"
                        End With
                End If
                End If
        Next myCell
        Application.ScreenUpdating = True
End Sub

However, as each of the printed sheets consists of three pages and the designated printer has a built in stapler i would very much like for it to staple my printouts as I otherwise would have to do it manually.

Even though the xlDialogPrinterSetup dialog allows me to choose the settings for the printer (driver-specific settings that is), the settings are not applied.

Why is that and how do I proceed?

Thanks in advance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top