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

沒有留言:

張貼留言

我的雷達:20260304 突破海峽!!!

  2號指標也亮燈,就衝!!!!! 更新:20260307 過一段時間了,才敢貼交易明細 哈,因為跟外資持股對答案 2026/3/9 訊號再次出現(數字衝高到1617),就買買買買買買 但我還是豬頭買了台達化