PDA

View Full Version : [SOLVED:] Legacy .dot vba to Word 2013 .docm



phil210802
09-02-2014, 08:36 AM
I have inherited the following code that I need to update to word 2013 format (or at least that it will work in Word 2013), the part I have problem with is the part highlighted in BOLD I have given the whole code incase there is something that this references that is causing this not to work.

'''REMEMBER !!!!!!!!!!!!!!!!!!
'''W2K AND XP PRINTING VIA ACTIVE PRINTER COMMAND
'''W98 ETC VIA DIALOG BOX


Option Explicit
Option Compare Text
Dim NumberofCopies As Integer
Dim PrinterName As String
Dim CurrentPrinter As String
'Const Location = "C:\AIM Legal Word Customisation\Word Customisation Ini File\Users.ini"
Const Location = "\\mwlaw.co.uk\M&W Word Customisation\Word Customisation Ini File\Users.ini"
Const Path = "\\mwlaw.co.uk\"
''
Private Sub cbSelective_Click()
'switch between normal and selective print


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


If Current_Printer$ = "MW-BAR-PRT1" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-PB-PRT1" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-PB-PRT3" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-BAR-PRT2" Then
GoTo HP2200
ElseIf Current_Printer$ = "MW-PB-PRT2" Then
GoTo HP2200
ElseIf Current_Printer$ = "MW-PB-PRT4" Then
GoTo HP2200
End If


HP2200:
If cbSelective.Value = True Then
obLetter.Enabled = False
obLetterCopy.Enabled = False
obLetterCopies2.Enabled = False
obCopy.Enabled = False
obPlain.Enabled = False
obManual.Enabled = False
obBill.Enabled = False
obDuplexPlain.Enabled = False
obDuplexManual.Enabled = False
obPrintAll.Enabled = True
obPrintCurrent.Enabled = True
obPrintPages.Enabled = True
txtPrintPages.Enabled = True
obTray1.Enabled = True
obTray2.Enabled = True
obTray3.Enabled = False
obTray4.Enabled = False
obTrayManual.Enabled = False
obBillManual.Enabled = True
lbPageDetails.Enabled = True
lbTraySelection.Enabled = True
cbDuplex.Enabled = True
Else
obLetter.Enabled = True
obLetterCopy.Enabled = True
obLetterCopies2.Enabled = True
obCopy.Enabled = False
obPlain.Enabled = True
obManual.Enabled = True
obBill.Enabled = True
obDuplexPlain.Enabled = True
obDuplexManual.Enabled = True
obPrintAll.Enabled = False
obPrintCurrent.Enabled = False
obPrintPages.Enabled = False
txtPrintPages.Enabled = False
obTray1.Enabled = False
obTray2.Enabled = False
obTray3.Enabled = False
obTray4.Enabled = False
obTrayManual.Enabled = False
obBillManual.Enabled = False
lbPageDetails.Enabled = False
lbTraySelection.Enabled = False
cbDuplex.Enabled = False
End If
GoTo Complete


Canon:
If cbSelective.Value = True Then
obLetter.Enabled = False
obLetterCopy.Enabled = False
obLetterCopies2.Enabled = False
obCopy.Enabled = False
obPlain.Enabled = False
obManual.Enabled = False
obBill.Enabled = False
obDuplexPlain.Enabled = False
obDuplexManual.Enabled = False
obPrintAll.Enabled = True
obPrintCurrent.Enabled = True
obPrintPages.Enabled = True
txtPrintPages.Enabled = True
obTray1.Enabled = True
obTray2.Enabled = True
obTray3.Enabled = True
obTray4.Enabled = True
obTrayManual.Enabled = True
obBillManual.Enabled = False
lbPageDetails.Enabled = True
lbTraySelection.Enabled = True
cbDuplex.Enabled = True
Else
obLetter.Enabled = True
obLetterCopy.Enabled = True
obLetterCopies2.Enabled = True
obCopy.Enabled = False
obPlain.Enabled = True
obManual.Enabled = True
obBill.Enabled = True
obDuplexPlain.Enabled = True
obDuplexManual.Enabled = True
obPrintAll.Enabled = False
obPrintCurrent.Enabled = False
obPrintPages.Enabled = False
txtPrintPages.Enabled = False
obTray1.Enabled = False
obTray2.Enabled = False
obTray3.Enabled = False
obTray4.Enabled = False
obTrayManual.Enabled = False
obBillManual.Enabled = False
lbPageDetails.Enabled = False
lbTraySelection.Enabled = False
cbDuplex.Enabled = False
End If
GoTo Complete


Complete:
End Sub
Private Sub cmbPrinterArray_Change()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


If Current_Printer$ = "MW-BAR-PRT1" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-PB-PRT1" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-PB-PRT3" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-BAR-PRT2" Then
GoTo HP2200
ElseIf Current_Printer$ = "MW-PB-PRT2" Then
GoTo HP2200
ElseIf Current_Printer$ = "MW-PB-PRT4" Then
GoTo HP2200
End If


HP2200:
If cbSelective.Value = True Then
obLetter.Enabled = False
obLetterCopy.Enabled = False
obLetterCopies2.Enabled = False
obCopy.Enabled = False
obPlain.Enabled = False
obManual.Enabled = False
obBill.Enabled = False
obDuplexPlain.Enabled = False
obDuplexManual.Enabled = False
obPrintAll.Enabled = True
obPrintCurrent.Enabled = True
obPrintPages.Enabled = True
txtPrintPages.Enabled = True
obTray1.Enabled = True
obTray2.Enabled = True
obTray3.Enabled = False
obTray4.Enabled = False
obTrayManual.Enabled = False
obBillManual.Enabled = True
lbPageDetails.Enabled = True
lbTraySelection.Enabled = True
cbDuplex.Enabled = True
Else
obLetter.Enabled = True
obLetterCopy.Enabled = True
obLetterCopies2.Enabled = True
obCopy.Enabled = False
obPlain.Enabled = True
obManual.Enabled = True
obBill.Enabled = True
obDuplexPlain.Enabled = True
obDuplexManual.Enabled = True
obPrintAll.Enabled = False
obPrintCurrent.Enabled = False
obPrintPages.Enabled = False
txtPrintPages.Enabled = False
obTray1.Enabled = False
obTray2.Enabled = False
obTray3.Enabled = False
obTray4.Enabled = False
obTrayManual.Enabled = False
obBillManual.Enabled = False
lbPageDetails.Enabled = False
lbTraySelection.Enabled = False
cbDuplex.Enabled = False
End If
GoTo Complete


Canon:
If cbSelective.Value = True Then
obLetter.Enabled = False
obLetterCopy.Enabled = False
obLetterCopies2.Enabled = False
obCopy.Enabled = False
obPlain.Enabled = False
obManual.Enabled = False
obBill.Enabled = False
obDuplexPlain.Enabled = False
obDuplexManual.Enabled = False
obPrintAll.Enabled = True
obPrintCurrent.Enabled = True
obPrintPages.Enabled = True
txtPrintPages.Enabled = True
obTray1.Enabled = True
obTray2.Enabled = True
obTray3.Enabled = True
obTray4.Enabled = True
obTrayManual.Enabled = True
obBillManual.Enabled = False
lbPageDetails.Enabled = True
lbTraySelection.Enabled = True
cbDuplex.Enabled = True
Else
obLetter.Enabled = True
obLetterCopy.Enabled = True
obLetterCopies2.Enabled = True
obCopy.Enabled = False
obPlain.Enabled = True
obManual.Enabled = True
obBill.Enabled = True
obDuplexPlain.Enabled = True
obDuplexManual.Enabled = True
obPrintAll.Enabled = False
obPrintCurrent.Enabled = False
obPrintPages.Enabled = False
txtPrintPages.Enabled = False
obTray1.Enabled = False
obTray2.Enabled = False
obTray3.Enabled = False
obTray4.Enabled = False
obTrayManual.Enabled = False
obBillManual.Enabled = False
lbPageDetails.Enabled = False
lbTraySelection.Enabled = False
cbDuplex.Enabled = False
End If
GoTo Complete


Complete:
End Sub


'cancel button
Private Sub cmdCancel_Click()
Unload PrinterFrm
End Sub


Private Sub frmNetworkPrinters_Click()


End Sub


Private Sub frmSelectivePrinting_Click()


End Sub


Private Sub obPrintCurrent_Click()


End Sub


Private Sub obTray4_Click()


End Sub


Private Sub UserForm_Initialize()


Dim Current_Printer$


ActiveWindow.View.Type = wdPrintView


Start:
cmbPrinterArray.AddItem "" 'Printer Array, lists the printers
cmbPrinterArray.AddItem "MW-BAR-PRT1"
cmbPrinterArray.AddItem "MW-BAR-PRT2"
cmbPrinterArray.AddItem "MW-PB-PRT1"
cmbPrinterArray.AddItem "MW-PB-PRT2"
cmbPrinterArray.AddItem "MW-PB-PRT3"
cmbPrinterArray.AddItem "MW-PB-PRT4"




cmbPrinterArray.ListIndex = 0 ' sets the default item


lbDefaultPrinter.Caption = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer")


If System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") = "" Then
MsgBox "You need to select a Default Printer", vbCritical, "Male & Wagland"
frmUserDetails.Show
Exit Sub
End If


GoTo Complete


Complete:
End Sub


Private Sub cmdPrint_Click() ' Print button

Application.ScreenUpdating = False 'turns the screen updating off

On Error GoTo wrong

NumberofCopies = Val(txtNumberCopies.Text) ' number of Copies required

If NumberofCopies <= 0 Then 'error message if no copies selected
MsgBox "please enter the number of copies required", vbInformation, "COMPANY NAME"""
txtNumberCopies.SetFocus
Printer.EndDoc
Exit Sub
End If


'Standard or Selective print options
If cbSelective.Value = True Then
SelectivePrint
Else
StandardPrint
End If
GoTo Complete


wrong: 'error label
MsgBox "There is a problem with your Printer, please contact your Administrator", _
vbCritical, "Male & Wagland"
Unload Me


Complete:
Application.ScreenUpdating = True 'turn screen refreshing on
End Sub


Sub SelectivePrint()


Dim Current_Printer$

' if no value selected use the information stored within the ini file
If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer")
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


'checking that only valid printer selected
If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


If Current_Printer$ = "MW-BAR-PRT1" Then
GoTo Start
ElseIf Current_Printer$ = "MW-BAR-PRT2" Then
GoTo Start
ElseIf Current_Printer$ = "MW-PB-PRT1" Then
GoTo Start
ElseIf Current_Printer$ = "MW-PB-PRT2" Then
GoTo Start
ElseIf Current_Printer$ = "MW-PB-PRT3" Then
GoTo Start
ElseIf Current_Printer$ = "MW-PB-PRT4" Then
GoTo Start
Else:
MsgBox "Please select a printer from the list", vbCritical, "Male & Wagland"
cmbPrinterArray.Value = "" 'clear typed text
cmbPrinterArray.SetFocus 'set focus on printer array
Exit Sub
End If


Start:


' checking if an option is not selected
If cbSelective.Value = True And _
(obTray1.Value = False And _
obTray2.Value = False And _
obTray3.Value = False And _
obTray4.Value = False And _
obTrayManual.Value = False And _
obBillManual.Value = False) Then
'error message
MsgBox "Select tray to print from", vbInformation, "Male & Wagland"
Exit Sub
End If


SetTrays 'set printer trays


If cbDuplex.Value = True Then
GoTo Duplex
Else
GoTo NonDuplex
End If


Duplex:


'Print all
If obPrintAll.Value = True Then
Update
ActivePrinter = Path + Current_Printer$ + "d"
Application.PrintOut FileName:="", Item:=wdPrintDocumentContent, _
Copies:=NumberofCopies, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
End If


If obPrintCurrent.Value = True Then
'Update ' do not set will default away from selected page
ActivePrinter = Path + Current_Printer$ + "D"
Application.PrintOut FileName:="", Range:=wdPrintCurrentPage, Item:= _
wdPrintDocumentContent, Copies:=NumberofCopies, Pages:="", _
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
End If


If obPrintPages.Value = True Then
Update
ActivePrinter = Path + Current_Printer$ + "D"
'checking page range
If cbSelective.Value = True And _
(txtPrintPages.Value = "") Then
'error message
MsgBox "Please enter a page range", vbInformation, "Male & Wagland"
txtPrintPages.SetFocus
Exit Sub
End If


Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=NumberofCopies, _
Pages:=txtPrintPages.Text, PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False
End If
GoTo Complete


'***********************************************


NonDuplex:
'Print all
If obPrintAll.Value = True Then
Update
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Item:=wdPrintDocumentContent, _
Copies:=NumberofCopies, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
End If


If obPrintCurrent.Value = True Then
'Update ' do not set will default away from selected page
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Range:=wdPrintCurrentPage, Item:= _
wdPrintDocumentContent, Copies:=NumberofCopies, Pages:="", _
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
End If


If obPrintPages.Value = True Then
Update
ActivePrinter = Path + Current_Printer$
'checking page range
If cbSelective.Value = True And _
(txtPrintPages.Value = "") Then
'error message
MsgBox "Please enter a page range", vbInformation, "Male & Wagland"
txtPrintPages.SetFocus
Exit Sub
End If


Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=NumberofCopies, _
Pages:=txtPrintPages.Text, PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False
End If
Complete:
Unload Me
End Sub


Sub StandardPrint()
Dim Current_Printer$


' checking if options selected
If cbSelective.Value = False And _
(obLetter.Value = False And _
obLetterCopy.Value = False And _
obLetterCopies2.Value = False And _
obCopy.Value = False And _
obPlain.Value = False And _
obManual.Value = False And _
obBill.Value = False And _
obDuplexPlain.Value = False And _
obDuplexManual.Value = False) Then
MsgBox "Select type of printing", vbInformation, "Male & Wagland"
Exit Sub
End If


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


If Current_Printer$ = "MW-BAR-PRT1" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-BAR-PRT2" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-PB-PRT1" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-PB-PRT3" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-BAR-PRT2" Then
GoTo HP2200
ElseIf Current_Printer$ = "MW-PB-PRT2" Then
GoTo HP2200
ElseIf Current_Printer$ = "MW-PB-PRT4" Then
GoTo HP2200
End If


'*************************************************
HP2200:
'Letter
If obLetter.Value = True Then
HP2200Letter
End If


'Letter & Copy
If obLetterCopy.Value = True Then
HP2200LetterCopy
End If


'Letter & 2 Copies
If obLetterCopies2.Value = True Then
HP2200Letter2Copy
End If


'Copy
If obCopy = True Then
HP2200Copy
End If


'Plain
If obPlain = True Then
HP2200Plain
End If


'Manual
If obManual.Value = True Then
HP2200Manual
End If


'Bill & 2 copies
'pages 1-2 duplex - remaining simplex


If obBill.Value = True Then
HP2200Bill
End If


' Duplex Plain:
If obDuplexPlain.Value = True Then
HP2200DuplexPlain
End If


'Duplex Manual
If obDuplexManual.Value = True Then
HP2200DuplexManual
End If


GoTo Complete


'***************************
'***************************
Canon:


'Letter
If obLetter.Value = True Then
CannonLetter
End If


'Letter & Copy
If obLetterCopy.Value = True Then
CannonLetterCopy
End If




'Letter & 2 Copies
If obLetterCopies2.Value = True Then
CannonLetter2Copy
End If


'copy
If obCopy = True Then
CannonCopy
End If


'Plain
If obPlain = True Then
CannonPlain
End If


'Manual
If obManual.Value = True Then
CannonManual
End If


'Bill & Copy
If obBill.Value = True Then
CannonBill
End If


' Duplex Plain:
If obDuplexPlain.Value = True Then
CannonDuplexPlain
End If


'Duplex Manual
If obDuplexManual.Value = True Then
CannonDuplexManual
End If


GoTo Complete


Complete:
Unload Me
End Sub


Sub SetTrays()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


If Current_Printer$ = "MW-BAR-PRT1" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-BAR-PRT2" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-PB-PRT1" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-PB-PRT3" Then
GoTo Canon
ElseIf Current_Printer$ = "MW-BAR-PRT2" Then
GoTo HP2200
ElseIf Current_Printer$ = "MW-PB-PRT2" Then
GoTo HP2200
ElseIf Current_Printer$ = "MW-PB-PRT4" Then
GoTo HP2200
End If


'**********************************


HP2200:
If obTray1.Value = True Then
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin
End With
End If


If obTray2.Value = True Then
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
End If


If obBillManual.Value = True Then
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterManualFeed
.OtherPagesTray = wdPrinterManualFeed
End With
End If
GoTo Complete


'***************************
'***************************
Canon:
'letterhead
If obTray1.Value = True Then
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterUpperBin
.OtherPagesTray = wdPrinterUpperBin
End With
End If


'Plain
If obTray2.Value = True Then
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterMiddleBin
.OtherPagesTray = wdPrinterMiddleBin
End With
End If


'Plain
If obTray3.Value = True Then
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin
End With
End If


'bill
If obTray4.Value = True Then
With ActiveDocument.PageSetup
.FirstPageTray = 264
.OtherPagesTray = 264
End With
End If


If obTrayManual.Value = True Then
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterManualFeed
.OtherPagesTray = wdPrinterManualFeed
End With
End If
GoTo Complete
Complete:
End Sub


Sub Remove()
'
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "{}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


Public Sub Update()


Application.ScreenUpdating = False
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.Fields.Update
Selection.HomeKey Unit:=wdStory


ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Fields.Update


ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument


Application.Browser.Target = wdBrowsePage
Application.Browser.Next
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument


Application.ScreenUpdating = True
End Sub
Sub HP2200Letter()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub HP2200LetterCopy()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
'Copy - Tray 2
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
'WaterMarkCopy
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
'WaterMarkRemove
Unload Me
End Sub


Sub HP2200Letter2Copy()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=1, Background:=True
'2 Copies - Tray 3
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
' WaterMarkCopy
Application.PrintOut FileName:="", Copies:=2, Background:=True
' WaterMarkRemove
Unload Me
End Sub


Sub HP2200Copy()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
ActivePrinter = Path + Current_Printer$
' WaterMarkCopy
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
' WaterMarkRemove
Unload Me
End Sub


Sub HP2200Plain()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub HP2200Manual()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterUpperBin
.OtherPagesTray = wdPrinterUpperBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub HP2200Bill()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterUpperBin
.OtherPagesTray = wdPrinterUpperBin
End With
ActivePrinter = Path + Current_Printer$ + "D"
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="2-3", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0


With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="1,4-15", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0


'Copy - Tray 2
With ActiveDocument.PageSetup 'print pages 2-15 no taxation
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
'WaterMarkCopy
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=2, Pages:="3-15", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
'WaterMarkRemove
Unload Me
End Sub


Sub HP2200DuplexPlain()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLargeCapacityBin
.OtherPagesTray = wdPrinterLargeCapacityBin
End With
ActivePrinter = Path + Current_Printer$ + "D"
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub HP2200DuplexManual()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterUpperBin
.OtherPagesTray = wdPrinterUpperBin
End With
ActivePrinter = Path + Current_Printer$ + "D"
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub CannonLetter()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterUpperBin
.OtherPagesTray = wdPrinterMiddleBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub CannonLetterCopy()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterUpperBin
.OtherPagesTray = wdPrinterMiddleBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True


'Copy - Tray 3
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin
End With
'WaterMarkCopy
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
'WaterMarkRemove
Unload Me
End Sub


Sub CannonLetter2Copy()
Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterUpperBin
.OtherPagesTray = wdPrinterMiddleBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=1, Background:=True
'2 Copies - Tray 2
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin
End With
'WaterMarkCopy
Application.PrintOut FileName:="", Copies:=2, Background:=True
' WaterMarkRemove
Unload Me
End Sub


Sub CannonCopy()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterMiddleBin
.OtherPagesTray = wdPrinterMiddleBin
End With
'WaterMarkCopy
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
' WaterMarkRemove
Unload Me
End Sub


Sub CannonPlain()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub CannonManual()
Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterManualFeed
.OtherPagesTray = wdPrinterManualFeed
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub CannonBill()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove


With ActiveDocument.PageSetup 'duplex 1st page - Taxation
.FirstPageTray = wdPrinterUpperBin
.OtherPagesTray = wdPrinterUpperBin
End With
ActivePrinter = Path + Current_Printer$ + "D" 'recorded macro
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="2-3", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0


With ActiveDocument.PageSetup 'simplex remaining pages
.FirstPageTray = wdPrinterMiddleBin
.OtherPagesTray = wdPrinterMiddleBin
End With
ActivePrinter = Path + Current_Printer$
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="1,4-15", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0


'Copy - Tray 2
With ActiveDocument.PageSetup 'copy no taxation page
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin
End With
'WaterMarkCopy
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=2, Pages:="3-15", PageType:= _
wdPrintAllPages, ManualDuplexPrint:=False, Collate:=True, Background:= _
True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
'WaterMarkRemove
Unload Me
End Sub


Sub CannonDuplexPlain()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterLowerBin
.OtherPagesTray = wdPrinterLowerBin
End With
ActivePrinter = Path + Current_Printer$ + "D"
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub


Sub CannonDuplexManual()


Dim Current_Printer$


If cmbPrinterArray.Value = "" Then
Current_Printer$ = System.PrivateProfileString(FileName:=Location, _
Section:=Application.UserName, Key:="Default Printer") ' stored within the ini file
Else
Current_Printer$ = cmbPrinterArray.Value ' use the printer selected from array
End If


Update
Remove
With ActiveDocument.PageSetup
.FirstPageTray = wdPrinterManualFeed
.OtherPagesTray = wdPrinterManualFeed
End With
ActivePrinter = Path + Current_Printer$ + "D"
Application.PrintOut FileName:="", Copies:=NumberofCopies, _
Background:=True
Unload Me
End Sub

fumei
09-02-2014, 03:13 PM
1. Please use the code tags when posting code.

2. I doubt anyone is going tp parse through all that code, especially you give NOTHING to give any meaning to what you "have problem" with. What exactly IS your problem?

macropod
09-02-2014, 03:14 PM
Expecting someone to review nearly 1500 lines of unformatted code (you didn't even use the code tags the forum provides for code formatting), looking for an undefined problem that occurs with a 33-line sub is a bit much. Perhaps you would cay to say what the problem actually is and - for future posts - use the code tags (indicated by the # symbol on the post/reply menu) when posting code.

phil210802
09-02-2014, 03:38 PM
Really sorry guys, new here :(

Bit of code I'm having problems with is amending the printer form and it not working when I click on Print button.


Private Sub cmdPrint_Click() ' Print button

Application.ScreenUpdating = False 'turns the screen updating off

On Error GoTo wrong

NumberofCopies = Val(txtNumberCopies.Text) ' number of Copies required

If NumberofCopies <= 0 Then 'error message if no copies selected
MsgBox "please enter the number of copies required", vbInformation, "COMPANY NAME"""
txtNumberCopies.SetFocus
Printer.EndDoc
Exit Sub

Thanks.

macropod
09-02-2014, 03:46 PM
And what, exactly, do you mean by this:
not working when I click on Print button.
In what circumstances isn't it working? Do you get an error message? If so, what does it say?

phil210802
09-02-2014, 03:51 PM
No error message, the button seems to click but that's it, the screen stays there (where as on the Office XP system when you clicked on Print it sent the job to the printer and the screen closed down). BTW I have created a new thread (was this the correct procedure)? if so please feel free to delete this thread.

macropod
09-02-2014, 04:17 PM
Please don't create new threads - especially not for topics already under discussion.

Have you tested:
• what the value of cbSelective.Value is?
• where, if at all, either of the SelectivePrint or StandardPrint modules get to?