A couple of machines in the office have recently upgraded to word 2003 and the printing macros for these machines are working intermittently.
The macro takes the computer name and a printer tray name stored in a text file and passes them through the macro to print out on the respective trays. i.e. intTray3 is Tray3.
I haven’t had much experience with word 2003 so any direction or help is appreciated
Expand|Select|Wrap|Line Numbers
- Option Explicit
- Option Compare Text
- Const cTray1 = 1
- Const cTray2 = 2
- Const cTray3 = 11
- Public intTray1 As Integer
- Public intTray2 As Integer
- Public intTray3 As Integer
- Sub AutoExec()
- On Error Resume Next
- Dim varFile()
- Dim varText
- Dim strText As String
- Dim strPCName As String
- Dim strPath As String
- Dim intFile As Integer
- Dim intLen As Integer
- Dim intPos As Integer
- Dim intLast As Integer
- 'Initialize
- intTray1 = cTray1
- intTray2 = cTray2
- intTray3 = cTray3
- strPCName = Environ("COMPUTERNAME")
- strPath = Project.ThisDocument.FullName
- strPath = Left(strPath, InStrRev(strPath, "\"))
- strPath = strPath & "LWR.txt"
- intFile = FreeFile
- Open strPath For Input As #intFile
- Do Until EOF(intFile)
- intLen = intLen + 1
- Input #intFile, varText
- 'ReDim Preserve varFile(intLen)
- 'varFile(intLen) = varText
- strText = CStr(varText)
- intPos = InStr(strText, ";")
- If Left(strText, intPos - 1) = strPCName Then
- 'This is the pc
- intLast = intPos + 1
- intPos = InStr(intLast, strText, ";")
- intTray1 = CInt(Mid(strText, intLast, intPos - intLast))
- intLast = intPos + 1
- intPos = InStr(intLast, strText, ";")
- intTray2 = CInt(Mid(strText, intLast, intPos - intLast))
- intLast = intPos + 1
- intPos = InStr(intLast, strText, ";")
- intTray3 = CInt(Mid(strText, intLast, intPos - intLast))
- Debug.Print intTray1 & " " & intTray2 & " " & intTray3
- Exit Do
- End If
- varText = Null
- Loop
- Close #intFile
- End Sub
- Sub DocWhite()
- On Error Resume Next
- With ActiveDocument.PageSetup
- .LineNumbering.Active = False
- .Orientation = wdOrientPortrait
- .TopMargin = InchesToPoints(1)
- .BottomMargin = InchesToPoints(1)
- .LeftMargin = InchesToPoints(1.25)
- .RightMargin = InchesToPoints(1.25)
- .Gutter = InchesToPoints(0)
- .HeaderDistance = InchesToPoints(0.5)
- .FooterDistance = InchesToPoints(0.5)
- .PageWidth = InchesToPoints(8.5)
- .PageHeight = InchesToPoints(11)
- .FirstPageTray = intTray3
- .OtherPagesTray = intTray3
- .SectionStart = wdSectionNewPage
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = False
- .VerticalAlignment = wdAlignVerticalTop
- .SuppressEndnotes = False
- .MirrorMargins = False
- .TwoPagesOnOne = False
- .GutterPos = wdGutterPosLeft
- End With
- Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
- wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
- ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
- False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
- PrintZoomPaperHeight:=0
- End Sub
- Sub DocBlue()
- On Error Resume Next
- With ActiveDocument.PageSetup
- .LineNumbering.Active = False
- .Orientation = wdOrientPortrait
- .TopMargin = InchesToPoints(1)
- .BottomMargin = InchesToPoints(1)
- .LeftMargin = InchesToPoints(1.25)
- .RightMargin = InchesToPoints(1.25)
- .Gutter = InchesToPoints(0)
- .HeaderDistance = InchesToPoints(0.5)
- .FooterDistance = InchesToPoints(0.5)
- .PageWidth = InchesToPoints(8.5)
- .PageHeight = InchesToPoints(11)
- .FirstPageTray = intTray1
- .OtherPagesTray = intTray1
- .SectionStart = wdSectionNewPage
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = False
- .VerticalAlignment = wdAlignVerticalTop
- .SuppressEndnotes = False
- .MirrorMargins = False
- .TwoPagesOnOne = False
- .GutterPos = wdGutterPosLeft
- End With
- Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
- wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
- Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
- PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
- End Sub
- Sub HeadWhite()
- On Error Resume Next
- With ActiveDocument.PageSetup
- .LineNumbering.Active = False
- .Orientation = wdOrientPortrait
- .TopMargin = InchesToPoints(0.38)
- .BottomMargin = InchesToPoints(1.5)
- .LeftMargin = InchesToPoints(0.88)
- .RightMargin = InchesToPoints(0.39)
- .Gutter = InchesToPoints(0)
- .HeaderDistance = InchesToPoints(0.37)
- .FooterDistance = InchesToPoints(0.03)
- .PageWidth = InchesToPoints(8.27)
- .PageHeight = InchesToPoints(11.69)
- .FirstPageTray = intTray3
- .OtherPagesTray = intTray3
- .SectionStart = wdSectionContinuous
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = True
- .VerticalAlignment = wdAlignVerticalTop
- .SuppressEndnotes = False
- .MirrorMargins = False
- .TwoPagesOnOne = False
- .GutterPos = wdGutterPosLeft
- End With
- Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
- wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
- Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
- PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
- End Sub
- Sub HeadGreen()
- On Error Resume Next
- With ActiveDocument.PageSetup
- .LineNumbering.Active = False
- .Orientation = wdOrientPortrait
- .TopMargin = InchesToPoints(0.38)
- .BottomMargin = InchesToPoints(1.5)
- .LeftMargin = InchesToPoints(0.88)
- .RightMargin = InchesToPoints(0.39)
- .Gutter = InchesToPoints(0)
- .HeaderDistance = InchesToPoints(0.37)
- .FooterDistance = InchesToPoints(0.03)
- .PageWidth = InchesToPoints(8.27)
- .PageHeight = InchesToPoints(11.69)
- .FirstPageTray = intTray2
- .OtherPagesTray = intTray2
- .SectionStart = wdSectionNewPage
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = False
- .VerticalAlignment = wdAlignVerticalTop
- .SuppressEndnotes = False
- .MirrorMargins = False
- .TwoPagesOnOne = False
- .GutterPos = wdGutterPosLeft
- End With
- Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
- wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
- Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
- PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
- End Sub
- Sub HeadMain()
- On Error Resume Next
- 'White and Green
- With ActiveDocument.PageSetup
- .LineNumbering.Active = False
- .Orientation = wdOrientPortrait
- .TopMargin = InchesToPoints(0.38)
- .BottomMargin = InchesToPoints(1.5)
- .LeftMargin = InchesToPoints(0.88)
- .RightMargin = InchesToPoints(0.39)
- .Gutter = InchesToPoints(0)
- .HeaderDistance = InchesToPoints(0.37)
- .FooterDistance = InchesToPoints(0.03)
- .PageWidth = InchesToPoints(8.27)
- .PageHeight = InchesToPoints(11.69)
- .FirstPageTray = intTray3
- .OtherPagesTray = intTray3
- .SectionStart = wdSectionContinuous
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = True
- .VerticalAlignment = wdAlignVerticalTop
- .SuppressEndnotes = False
- .MirrorMargins = False
- .TwoPagesOnOne = False
- .GutterPos = wdGutterPosLeft
- End With
- Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
- wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
- Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
- PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
- With ActiveDocument.PageSetup
- .LineNumbering.Active = False
- .Orientation = wdOrientPortrait
- .TopMargin = InchesToPoints(0.38)
- .BottomMargin = InchesToPoints(1.5)
- .LeftMargin = InchesToPoints(0.88)
- .RightMargin = InchesToPoints(0.39)
- .Gutter = InchesToPoints(0)
- .HeaderDistance = InchesToPoints(0.37)
- .FooterDistance = InchesToPoints(0.03)
- .PageWidth = InchesToPoints(8.27)
- .PageHeight = InchesToPoints(11.69)
- .FirstPageTray = intTray2
- .OtherPagesTray = intTray2
- .SectionStart = wdSectionContinuous
- .OddAndEvenPagesHeaderFooter = False
- .DifferentFirstPageHeaderFooter = True
- .VerticalAlignment = wdAlignVerticalTop
- .SuppressEndnotes = False
- .MirrorMargins = False
- .TwoPagesOnOne = False
- .GutterPos = wdGutterPosLeft
- End With
- Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
- wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
- Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
- PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
- End Sub