View Single Post
 
Old 01-26-2017, 08:26 AM
Leftovercity Leftovercity is offline Mac OS X Office 2016
Novice
 
Join Date: Jan 2017
Posts: 3
Leftovercity is on a distinguished road
Default Macro Code for Duplex Printing

Hi Everyone,

First time on here. I'm new to Macros but got one working that creates sequential numbering page to page. But now my issues is that the document I need it for is two pages and I need it to be printed two sided (Duplex). When I run the Macro it bypasses the printer setting window and prints two individual pages. Is there a Macro code I can add to run duplex printing?

Here's my current code:

Code:
Dim Message As String, Title As String, Default As String, NumCopies As Long
Dim Rng1 As Range

' Set prompt.
Message = "Enter the number of copies that you want to print"
' Set title.
Title = "Print"
' Set default.
Default = "1"

' Display message, title, and default value.
NumCopies = Val(InputBox(Message, Title, Default))
SerialNumber = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "SerialNumber")

If SerialNumber = "" Then
  SerialNumber = 1
End If

Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range
Counter = 0

While Counter < NumCopies
  Rng1.Delete
  Rng1.Text = Format(SerialNumber, "0000")
  ActiveDocument.PrintOut
  SerialNumber = SerialNumber + 1
  Counter = Counter + 1
Wend

'Save the next number back to the Settings.txt file ready for the next use.
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
  "SerialNumber") = SerialNumber

'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
  .Add Name:="SerialNumber", Range:=Rng1
End With

ActiveDocument.Save

Last edited by macropod; 01-26-2017 at 03:54 PM. Reason: Added code tags and formatting
Reply With Quote