2024年1月8日 星期一

VBA入門: 列印設定玩玩 ActiveSheet.PrintOut、ActiveSheet.PageSetup

一個例子,小編先設定5個列印設定,若無此需要,也可以直接

ActiveSheet.PrintOut , ActivePrinter:=""直接上也可以。

1.列印儲存格範圍:PrintArea

2.設定列印上下作右邊界:

PageSetup.TopMargin、PageSetup.BottomMargin、PageSetup.LeftMargin PageSetup.RightMargin 

3.然後設定列印方向:Orientation 

4.設定寬度與長度:FitToPagesWide 、FitToPagesTall 

5.設定使用的印表機:ActiveSheet.PrintOut , ActivePrinter:=???

Sub  DO_PRINT()

    print_t="印表機名稱"

            ActiveSheet.PageSetup.PrintArea = "a1:I68"          

            With ActiveSheet.PageSetup

             .TopMargin = Application.CentimetersToPoints(0)

             .BottomMargin = Application.CentimetersToPoints(0)

             .LeftMargin = Application.CentimetersToPoints(0)

             .RightMargin = Application.InchesToPoints(0)

            End With  

            ActiveSheet.PageSetup.Orientation = 1 

            ActiveSheet.PageSetup.FitToPagesWide = 1 

            ActiveSheet.PageSetup.FitToPagesTall = 1

             ActiveSheet.PrintOut , ActivePrinter:=print_t

End Sub


簡短分享。

沒有留言:

張貼留言

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

 指數變化(2026.6.26) 開始透過AI做整理 一、上周焦點: 個人所得(月增率):約 0.7%,高於前月 0%(6/25 公佈)。 個人消費支出 PCE(月增率,名目):約 0.7%。 核心 PCE 物價(年增率):大致符合市場預期,維持在「溫和但偏高」區間。 通膨解讀:...