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


簡短分享。

沒有留言:

張貼留言

職場毒癌:把「同學」當「免費顧問」。當我來寫作業歐

故事來自某個EMBA傳說—— 有位做無人VAN的先進,還自己開顧問公司。 一起休學分同班同學們很好奇,約來服務公司喝咖啡「聊聊天」,解決公司困難。 結果呢? 需求講了、困難講了、流程拆了、解法問了,一輪全上。 聊著聊著,直接變半場顧問會議。 你還以為這叫交流? 拜託。 一起修過幾...