It is possible that when the user runs the code below and clicks No in the first messagebox that a SENDKEYS routine of Alt+F+P+D, followed by a wait for the user to select 'Print on Both Sides' is run?
Then after the user has made the selection another SENDKEYS routine of Esc Alt+S+Y is run the initiate the rest of the macro.
Or is there another better way of achieving the leadup into the main part of the routine?
Code:
Sub PrintNumberedCopiesEntireDocument()
'
' PrintNumberedCopiesEntireDocument Macro
' Shortcut keys Alt+E
'
Dim Msg As String, Ans As Variant
Dim lCopiesToPrint As Long
Dim lCounter As Long
Dim lCopyNumFrom As Long
Ans = MsgBox(Space(1) & "Is the document print settings configured for 'Print on Both Sides?" & vbCrLf & vbCrLf & _
"If not then click 'No', click the 'File' tab, 'Print', select 'Print on Both Sides / Flip pages on long edge' and then press 'Alt+S'.", _
vbMsgBoxSetForeground + vbQuestion + vbYesNoCancel, (Space(50) & "ABCDF 1234"))
Select Case Ans
Case vbYes
Case vbNo
End
Case vbCancel
End
End Select
' ask how many to print
On Error GoTo Canceled
lCopiesToPrint = InputBox( _
Prompt:="How many copies do you require?", _
Title:=(Space(45) & "ABCDF 1234"), _
Default:="1")
' ask where to start numbering
On Error GoTo Canceled
lCopyNumFrom = InputBox( _
Prompt:="Number at which to start numbering copies?", _
Title:=(Space(45) & "ABCDF 1234"), _
Default:=CStr(ActiveDocument.Variables("CopyNum") + 1))
' loop through the print-write-print cycle
For lCounter = 0 To lCopiesToPrint - 1
' update the document variable
ActiveDocument.Variables("CopyNum") = _
lCopyNumFrom + lCounter
With Options
.UpdateFieldsAtPrint = False
.UpdateLinksAtPrint = True
End With
ActiveDocument.Fields.Update
' print this numbered copy
ActiveDocument.PrintOut Copies:=1
Next lCounter
Canceled:
End Sub
cheers
Mike