![]() |
|
#1
|
|||
|
|||
|
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
Mike |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with Case and Select case | brent chadwick | Word VBA | 34 | 10-18-2015 02:13 PM |
| Replace & case | Jennifer Murphy | Word | 1 | 02-11-2013 03:26 AM |
A macro that can insert FILENAME, sendkeys CTRL ALT T, paste clipboard, and nextline
|
kyjac85 | Word VBA | 13 | 09-20-2012 05:00 PM |
| Problem with the sendkeys in Win7 | vidyapakki | Excel Programming | 1 | 05-07-2012 11:10 PM |
From all UPPER CASE to Proper Case
|
davers | Word | 1 | 04-30-2009 12:41 PM |