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

沒有留言:

張貼留言

職場毒癌:你憑什麼以為你十年寒窗,抵得我三代從商

你憑什麼以為你十年寒窗,抵得我三代從商——這句話已經記不得是從哪裡看到的,可能是某部劇,也可能是某篇 FB 文章標題。 但最近,特別有感。 為什麼會有這種感觸? 職場上有個同事,一路慢慢升到課長,好歹也是管理職,雖說不上鐵飯碗,但在多數人眼裡也算穩定。 結果呢?輾轉換了兩個製造課...