Excel 13 crash when printing via userform

Copper Contributor

Hello dear friends.

have a mysterious problem.
the following code is in module.
Is even a macro generated by excel for printing.

It works fine until you give the print command via a userform.
Then there are sometimes automation errors, sometimes not enough memory and mostly a total crash.

I tried to get every line out and tried again.

If the line with ".Orientation = xlLandscape" is present, it crashes immediately.

What can be the cause?
Has anyone perhaps had something like this before?

I can't get any further

 

 

 

Sub print_Standart()
 
    Application.PrintCommunication = False
      With ThisWorkbook.Sheets("Standart").PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
      End With
     
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = "$B$2:$Z$80"
    Application.PrintCommunication = False
   

    With ThisWorkbook.Sheets("Standart").PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0)
        .RightMargin = Application.InchesToPoints(0)
        .TopMargin = Application.InchesToPoints(0)
        .BottomMargin = Application.InchesToPoints(0)
        .HeaderMargin = Application.InchesToPoints(0)
        .FooterMargin = Application.InchesToPoints(0)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlLandscape
        .Draft = False
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
   
    Application.PrintCommunication = True
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False

 

 

0 Replies