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

沒有留言:

張貼留言

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

  指數變化(2026.01.23) 開始透過AI做整理 上周焦點: 1/13消費者物價相關 美國消費者物價指數(CPI)年增率:2.7%(符合預期),月增率:0.3%。 美國核心CPI年增率:2.6%。 1/14企業庫存、房市、能源及房貸相關 美國企業庫存月增率:0.3%(10...