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


簡短分享。

沒有留言:

張貼留言

指數變化(2024.05.17)

指數變化(2024.05.17) 上周焦點:         5/9當周焦點                          事實:fed與非農就業,引起投資市場對降息有加速,但肯定的是,fed說不加息了。                        美國密西根大學信心指數 ...