Forum Discussion
girlfromkent
Jan 07, 2025Copper Contributor
Excel order number macro to print duplex
Hi All
I have an order form as an excel sheet with a simple macro that increases the order number by one and prints it onto the sheet.
Sub PrintCopiesWithNumbers2()
'UpdatebyEntendoffice20161031
Dim i As Integer
Application.ScreenUpdating = False
For i = 850 To 875
Range("D45").Value = "'00" & i
ActiveSheet.PrintOut
Next i
Application.ScreenUpdating = True
MsgBox "Complete"
End Sub
This works fine. However, I now want to print some text on the other side of the order form. I've added the text to the sheet and set the page print areas. How do I edit the macro so that it prints page 2 in duplex, then continues?
Thanks in advance :-)
- NikolinoDEGold Contributor
If your printer supports duplex printing, you can force duplex mode using the ActivePrinter property along with PrintOut.
Sub PrintCopiesWithNumbers2() Dim i As Integer Dim DuplexMode As Long Application.ScreenUpdating = False ' Set Duplex Mode (1 = Simplex, 2 = Vertical Duplex, 3 = Horizontal Duplex) DuplexMode = 2 ' Change to 3 if your printer requires horizontal duplex For i = 850 To 875 ' Update the order number Range("D45").Value = "'00" & i ' Print with duplex setting ActiveSheet.PageSetup.CenterHeader = "Order No: " & Range("D45").Value ActiveSheet.PrintOut Copies:=1, Collate:=True, ActivePrinter:=Application.ActivePrinter, _ PrintToFile:=False, PrToFileName:="", IgnorePrintAreas:=False Next i Application.ScreenUpdating = True MsgBox "Printing Complete" End Sub
I hope I was able to help you with this.