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

沒有留言:

張貼留言

指數變化(2025.08.29) 開始透過AI做整理

 指數變化(2025.08.29) 開始透過AI做整理 上周焦點: 8/19(二)   美國房屋開工率 5%月增  美國建築許可月增率 月增2.8% 8/20(三)   美國房貸綜合指數 月減0.5%  美國30年期房貸利率 6.69%  美國15年期房貸利率 5.8~5.71%...