Szukaj na tym blogu

Ustawienia obszaru wydruku w VBA

 

Sub ustaw_druk()

    Dim ostatni_wiersz As Long

    Dim pArea As String

    Dim i As Long

   

    Const ILE = 64 ' ile wierszy ma zawierać jedna strona wydruku

   

    ostatni_wiersz = ThisWorkbook.Worksheets(lista).Cells(Rows.Count, 1).End(xlUp).Row

    pArea = "$A$1:$C$" & ostatni_wiersz

   


       

        With ThisWorkbook.Worksheets(lista)

         

         .ResetAllPageBreaks

       

         For i = ILE + 1 To .Range(pArea).Rows.Count Step ILE

             .HPageBreaks.Add Before:=.Range(pArea).Cells(i, 1)

         Next

         

         With .PageSetup

            .PrintArea = pArea

            .Orientation = xlPortrait

            .Zoom = 85 ' dopasowanie wielkości strony żeby się zmieściło wszystko

            .LeftMargin = Application.InchesToPoints(0.2)

            .RightMargin = Application.InchesToPoints(0.2)

            .BottomMargin = Application.InchesToPoints(0.3)

            .TopMargin = Application.InchesToPoints(0.3)

         End With

         

               .PageSetup.PrintArea = ""

           

        End With


End Sub


Brak komentarzy:

Prześlij komentarz