2025年4月22日 星期二

VBA 雙面列印指定範圍

今天測試掌握了雙面列印技巧,但無奈VBA無法直接雙面列印。 Sub 雙面列印指定範圍() Dim ws1 As Worksheet, ws2 As Worksheet Set ws1 = ThisWorkbook.Sheets("工作表1") '替換為實際工作表名稱 Set ws2 = ThisWorkbook.Sheets("工作表2") '設定A4紙張大小 With ws1.PageSetup .PaperSize = xlPaperA4 .PrintArea = "A1:D20" '替換為實際列印範圍 End With With ws2.PageSetup .PaperSize = xlPaperA4 .PrintArea = "A1:F30" '替換為實際列印範圍 End With '列印設定 With ActiveWorkbook .PrintOut _ From:=1, _ To:=1, _ Copies:=1, _ Preview:=False, _ ActivePrinter:="", _ PrintToFile:=False, _ Collate:=True, _ PrToFileName:="", _ IgnorePrintAreas:=False '手動翻面後列印第二面 If MsgBox("請手動翻面後按確定", vbOKCancel) = vbOK Then .PrintOut _ From:=2, _ To:=2, _ Copies:=1, _ Preview:=False, _ ActivePrinter:="", _ PrintToFile:=False, _ Collate:=True, _ PrToFileName:="", _ IgnorePrintAreas:=False End If End With End Sub 這個方案還要手動。 最後結論,轉換成PDF,批次雙面列印效率更好。

沒有留言:

張貼留言

上市櫃營收年增率:2025.11

月年增率 114.11 上市櫃公司總營收與月年增率 月總營收 110/02 110/03 110/04 110/05 110/06 110/07 110/08 110/09 110/10 110/11 110/12 111/01 111/02 111/03 111/04 111/...