2024年4月6日 星期六

vba:vba 列印設定中,如果要設定列印邊界 怎做?

列印設定中,如果要設定列印邊界 怎做

是用 PageSetup列印屬性設定,有四個邊界可以設定

 Set ws = Sheets("Sheet1") '用Sheet1當作設定對像工作表名稱

    ' 設定列印儲存格範圍

    ws.PageSetup.PrintArea = "$A$1:$F$10    

    ' 設定邊界

    With ws.PageSetup

        .LeftMargin = Application.InchesToPoints(0.5) ' 設定0.5 英寸左邊界

        .RightMargin = Application.InchesToPoints(0.5) ' 設定0.5 英寸右邊界

        .TopMargin = Application.InchesToPoints(0.75) ' 設定0.75 英寸上邊界

        .BottomMargin = Application.InchesToPoints(0.75) ' 設定0.75 英寸下邊界

    End With


'公分版

  With ws.PageSetup

        .LeftMargin = Application.CentimetersToPoints(2.54) ' 設定左邊界 (2.54 公分 = 1 英寸)

        .RightMargin = Application.CentimetersToPoints(2.54) ' 設定右邊界 (2.54 公分 = 1 英寸)

        .TopMargin = Application.CentimetersToPoints(1.905) ' 設定上邊界 (1.905 公分 = 0.75 英寸)

        .BottomMargin = Application.CentimetersToPoints(1.905) ' 設定下邊界 (1.905 公分 = 0.75 英寸)

    End With

沒有留言:

張貼留言

我的雷達:20240506

自己紀錄給自己看。 在大跌1400多點後,拉回中。 雷達顯示遠離風險區但離前一個底(大盤高點也不遠了)