Forum Discussion

Moysoul's avatar
Moysoul
Copper Contributor
May 15, 2024
Solved

Printout macros problem

hello friends, I'm facing an issue when i record an macros to printout sheet using this code    Application.Dialogs(xlDialogPrinterSetup).Show ActiveWindow.SelectedSheets.PrintOut Copies:=1, ...
  • NikolinoDE's avatar
    NikolinoDE
    May 15, 2024

    Moysoul 

    Let's try a different approach 🙂

    Sub PrintWithPrinterSetup()
        Dim printerDialog As Variant
        
        ' Show printer setup dialog
        Set printerDialog = Application.Dialogs(xlDialogPrinterSetup)
        If Not printerDialog.Show Then
            MsgBox "Printing canceled by user.", vbExclamation
            Exit Sub
        End If
        
        ' Print only if the user didn't cancel
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
            IgnorePrintAreas:=False
    End Sub

    If that doesn't work either, please add more detailed information such as Excel version, operating system, storage medium, etc.
    If possible the file (without sensitive data).