Thanks, guys. Yes, here's my code. It used to work just fine (in both an
addin or as attached) until I tried to "clean it up" and broke it up into
separate, more comprehensible, subs. I'm wondering whether if I try to
capture the FilePrint event I ought to leave all the code within that sub or
something.....
Option Explicit
Sub FilePrintDefault()
' ActiveDocument.PrintOut
FilePrint
End Sub
Sub FilePrint()
' Dialogs(wdDialogFilePrint).Show
Dim docNum As String, T As Integer
Dim NumCopies As Integer
docNum = ActiveDocument.BuiltInDocumentProperties(1).Value
PrintNums
MsgBox "Back here"
End Sub
Sub PrintNums()
If docNum = "121" Then
p121
ElseIf docNum = "122" Then
p122
ElseIf docNum = "123" Then
p123
Else
Dialogs(wdDialogFilePrint).Show
End If
End Sub
Sub p121()
Dim T As Integer
On Error GoTo err_trap
reTryIt:
If ActiveDocument.CustomDocumentProperties("TOpages").Value = "two" Then
On Error GoTo 0
T = 2
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=2, Pages:="1",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=2, Pages:="2",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=3, Pages:="3",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=1, Pages:="4",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
Else
singlePage:
T = 1
singlePage_p121 T
End If
printAddlForms T
GoTo theEnd
err_trap:
If Err.Number = 5 Then 'no "TOPages" property, so one-page
ActiveDocument.CustomDocumentProperties.Add Name:="TOpages",
LinkToContent:=False, Type:=msoPropertyTypeString, Value:="one"
Err.Clear
On Error GoTo 0
GoTo singlePage
End If
theEnd:
End Sub
Sub singlePage_p121(T)
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=2, Pages:="1",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=3, Pages:="2",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=1, Pages:="3",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
End Sub
Sub printAddlForms(T) 'used in 121, 123
If T = 1 Then 'T indicates whether TO is one-page or two-pages
If ActiveDocument.CustomDocumentProperties("Print").Value = "DVFF"
Then
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=3, Pages:="4",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=2, Pages:="5",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
ElseIf ActiveDocument.CustomDocumentProperties("Print").Value = "DV"
Then
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=2, Pages:="4",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
ElseIf ActiveDocument.CustomDocumentProperties("Print").Value = "FF"
Then
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=3, Pages:="4",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
End If
ElseIf T = 2 Then
If ActiveDocument.CustomDocumentProperties("Print").Value = "DVFF"
Then
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=3, Pages:="5",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=2, Pages:="6",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
ElseIf ActiveDocument.CustomDocumentProperties("Print").Value = "DV"
Then
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=2, Pages:="5",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
ElseIf ActiveDocument.CustomDocumentProperties("Print").Value = "FF"
Then
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages,
Item:=wdPrintDocumentContent, copies:=3, Pages:="5",
pagetype:=wdPrintAllPages, manualduplexprint:=False, collate:=True,
Background:=True, printtofile:=False, printzoomcolumn:=0, printzoomrow:=0,
printzoompaperwidth:=0, printzoompaperheight:=0
End If
End If
End Sub
st.