473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

word 2003 - print marco

Hi,

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
  1. Option Explicit
  2. Option Compare Text
  3.  
  4. Const cTray1 = 1
  5. Const cTray2 = 2
  6. Const cTray3 = 11
  7.  
  8. Public intTray1 As Integer
  9. Public intTray2 As Integer
  10. Public intTray3 As Integer
  11.  
  12. Sub AutoExec()
  13. On Error Resume Next
  14.  
  15.     Dim varFile()
  16.     Dim varText
  17.     Dim strText As String
  18.     Dim strPCName As String
  19.     Dim strPath As String
  20.     Dim intFile As Integer
  21.     Dim intLen As Integer
  22.     Dim intPos As Integer
  23.     Dim intLast As Integer
  24.  
  25.     'Initialize
  26.     intTray1 = cTray1
  27.     intTray2 = cTray2
  28.     intTray3 = cTray3
  29.  
  30.     strPCName = Environ("COMPUTERNAME")
  31.     strPath = Project.ThisDocument.FullName
  32.     strPath = Left(strPath, InStrRev(strPath, "\"))
  33.  
  34.     strPath = strPath & "LWR.txt"
  35.  
  36.     intFile = FreeFile
  37.     Open strPath For Input As #intFile
  38.         Do Until EOF(intFile)
  39.             intLen = intLen + 1
  40.             Input #intFile, varText
  41.             'ReDim Preserve varFile(intLen)
  42.             'varFile(intLen) = varText
  43.             strText = CStr(varText)
  44.             intPos = InStr(strText, ";")
  45.             If Left(strText, intPos - 1) = strPCName Then
  46.                 'This is the pc
  47.                 intLast = intPos + 1
  48.                 intPos = InStr(intLast, strText, ";")
  49.                 intTray1 = CInt(Mid(strText, intLast, intPos - intLast))
  50.                 intLast = intPos + 1
  51.                 intPos = InStr(intLast, strText, ";")
  52.                 intTray2 = CInt(Mid(strText, intLast, intPos - intLast))
  53.                 intLast = intPos + 1
  54.                 intPos = InStr(intLast, strText, ";")
  55.                 intTray3 = CInt(Mid(strText, intLast, intPos - intLast))
  56.                 Debug.Print intTray1 & " " & intTray2 & " " & intTray3
  57.                 Exit Do
  58.             End If
  59.             varText = Null
  60.         Loop
  61.     Close #intFile
  62.  
  63. End Sub
  64. Sub DocWhite()
  65. On Error Resume Next
  66.  
  67.     With ActiveDocument.PageSetup
  68.         .LineNumbering.Active = False
  69.         .Orientation = wdOrientPortrait
  70.         .TopMargin = InchesToPoints(1)
  71.         .BottomMargin = InchesToPoints(1)
  72.         .LeftMargin = InchesToPoints(1.25)
  73.         .RightMargin = InchesToPoints(1.25)
  74.         .Gutter = InchesToPoints(0)
  75.         .HeaderDistance = InchesToPoints(0.5)
  76.         .FooterDistance = InchesToPoints(0.5)
  77.         .PageWidth = InchesToPoints(8.5)
  78.         .PageHeight = InchesToPoints(11)
  79.         .FirstPageTray = intTray3
  80.         .OtherPagesTray = intTray3
  81.         .SectionStart = wdSectionNewPage
  82.         .OddAndEvenPagesHeaderFooter = False
  83.         .DifferentFirstPageHeaderFooter = False
  84.         .VerticalAlignment = wdAlignVerticalTop
  85.         .SuppressEndnotes = False
  86.         .MirrorMargins = False
  87.         .TwoPagesOnOne = False
  88.         .GutterPos = wdGutterPosLeft
  89.     End With
  90.     Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
  91.         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
  92.         ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
  93.         False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
  94.         PrintZoomPaperHeight:=0
  95. End Sub
  96.  
  97. Sub DocBlue()
  98. On Error Resume Next
  99.  
  100.     With ActiveDocument.PageSetup
  101.         .LineNumbering.Active = False
  102.         .Orientation = wdOrientPortrait
  103.         .TopMargin = InchesToPoints(1)
  104.         .BottomMargin = InchesToPoints(1)
  105.         .LeftMargin = InchesToPoints(1.25)
  106.         .RightMargin = InchesToPoints(1.25)
  107.         .Gutter = InchesToPoints(0)
  108.         .HeaderDistance = InchesToPoints(0.5)
  109.         .FooterDistance = InchesToPoints(0.5)
  110.         .PageWidth = InchesToPoints(8.5)
  111.         .PageHeight = InchesToPoints(11)
  112.         .FirstPageTray = intTray1
  113.         .OtherPagesTray = intTray1
  114.         .SectionStart = wdSectionNewPage
  115.         .OddAndEvenPagesHeaderFooter = False
  116.         .DifferentFirstPageHeaderFooter = False
  117.         .VerticalAlignment = wdAlignVerticalTop
  118.         .SuppressEndnotes = False
  119.         .MirrorMargins = False
  120.         .TwoPagesOnOne = False
  121.         .GutterPos = wdGutterPosLeft
  122.     End With
  123.     Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
  124.         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
  125.         Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
  126.         PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
  127. End Sub
  128.  
  129. Sub HeadWhite()
  130. On Error Resume Next
  131.  
  132.     With ActiveDocument.PageSetup
  133.         .LineNumbering.Active = False
  134.         .Orientation = wdOrientPortrait
  135.         .TopMargin = InchesToPoints(0.38)
  136.         .BottomMargin = InchesToPoints(1.5)
  137.         .LeftMargin = InchesToPoints(0.88)
  138.         .RightMargin = InchesToPoints(0.39)
  139.         .Gutter = InchesToPoints(0)
  140.         .HeaderDistance = InchesToPoints(0.37)
  141.         .FooterDistance = InchesToPoints(0.03)
  142.         .PageWidth = InchesToPoints(8.27)
  143.         .PageHeight = InchesToPoints(11.69)
  144.         .FirstPageTray = intTray3
  145.         .OtherPagesTray = intTray3
  146.         .SectionStart = wdSectionContinuous
  147.         .OddAndEvenPagesHeaderFooter = False
  148.         .DifferentFirstPageHeaderFooter = True
  149.         .VerticalAlignment = wdAlignVerticalTop
  150.         .SuppressEndnotes = False
  151.         .MirrorMargins = False
  152.         .TwoPagesOnOne = False
  153.         .GutterPos = wdGutterPosLeft
  154.     End With
  155.     Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
  156.         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
  157.         Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
  158.         PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
  159. End Sub
  160.  
  161. Sub HeadGreen()
  162. On Error Resume Next
  163.  
  164.     With ActiveDocument.PageSetup
  165.         .LineNumbering.Active = False
  166.         .Orientation = wdOrientPortrait
  167.         .TopMargin = InchesToPoints(0.38)
  168.         .BottomMargin = InchesToPoints(1.5)
  169.         .LeftMargin = InchesToPoints(0.88)
  170.         .RightMargin = InchesToPoints(0.39)
  171.         .Gutter = InchesToPoints(0)
  172.         .HeaderDistance = InchesToPoints(0.37)
  173.         .FooterDistance = InchesToPoints(0.03)
  174.         .PageWidth = InchesToPoints(8.27)
  175.         .PageHeight = InchesToPoints(11.69)
  176.         .FirstPageTray = intTray2
  177.         .OtherPagesTray = intTray2
  178.         .SectionStart = wdSectionNewPage
  179.         .OddAndEvenPagesHeaderFooter = False
  180.         .DifferentFirstPageHeaderFooter = False
  181.         .VerticalAlignment = wdAlignVerticalTop
  182.         .SuppressEndnotes = False
  183.         .MirrorMargins = False
  184.         .TwoPagesOnOne = False
  185.         .GutterPos = wdGutterPosLeft
  186.     End With
  187.     Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
  188.         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
  189.         Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
  190.         PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
  191. End Sub
  192.  
  193. Sub HeadMain()
  194. On Error Resume Next
  195. 'White and Green
  196.  
  197.     With ActiveDocument.PageSetup
  198.         .LineNumbering.Active = False
  199.         .Orientation = wdOrientPortrait
  200.         .TopMargin = InchesToPoints(0.38)
  201.         .BottomMargin = InchesToPoints(1.5)
  202.         .LeftMargin = InchesToPoints(0.88)
  203.         .RightMargin = InchesToPoints(0.39)
  204.         .Gutter = InchesToPoints(0)
  205.         .HeaderDistance = InchesToPoints(0.37)
  206.         .FooterDistance = InchesToPoints(0.03)
  207.         .PageWidth = InchesToPoints(8.27)
  208.         .PageHeight = InchesToPoints(11.69)
  209.         .FirstPageTray = intTray3
  210.         .OtherPagesTray = intTray3
  211.         .SectionStart = wdSectionContinuous
  212.         .OddAndEvenPagesHeaderFooter = False
  213.         .DifferentFirstPageHeaderFooter = True
  214.         .VerticalAlignment = wdAlignVerticalTop
  215.         .SuppressEndnotes = False
  216.         .MirrorMargins = False
  217.         .TwoPagesOnOne = False
  218.         .GutterPos = wdGutterPosLeft
  219.     End With
  220.     Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
  221.         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
  222.         Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
  223.         PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
  224.     With ActiveDocument.PageSetup
  225.         .LineNumbering.Active = False
  226.         .Orientation = wdOrientPortrait
  227.         .TopMargin = InchesToPoints(0.38)
  228.         .BottomMargin = InchesToPoints(1.5)
  229.         .LeftMargin = InchesToPoints(0.88)
  230.         .RightMargin = InchesToPoints(0.39)
  231.         .Gutter = InchesToPoints(0)
  232.         .HeaderDistance = InchesToPoints(0.37)
  233.         .FooterDistance = InchesToPoints(0.03)
  234.         .PageWidth = InchesToPoints(8.27)
  235.         .PageHeight = InchesToPoints(11.69)
  236.         .FirstPageTray = intTray2
  237.         .OtherPagesTray = intTray2
  238.         .SectionStart = wdSectionContinuous
  239.         .OddAndEvenPagesHeaderFooter = False
  240.         .DifferentFirstPageHeaderFooter = True
  241.         .VerticalAlignment = wdAlignVerticalTop
  242.         .SuppressEndnotes = False
  243.         .MirrorMargins = False
  244.         .TwoPagesOnOne = False
  245.         .GutterPos = wdGutterPosLeft
  246.     End With
  247.     Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
  248.         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
  249.         Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
  250.         PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
  251. End Sub
Aug 14 '07 #1
0 1517

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Daniel Cloutier | last post by:
Hi, is it possible to edit or write Word-files out of a Python-Program? thx in advance daniel
2
by: Joe Black | last post by:
Hi My database is filling a Word docs with data using bookmarks. My client wants one particular document to print using the lower tray which will hav a special letterhead loaded in it. Is...
5
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
4
by: scorpion53061 | last post by:
I have my Word document being created in a seperate thread. THe applicaiton is not visible. The end user can choose to view the document upon completion or just have it print. Viewing is...
0
by: Daniel Sayer | last post by:
Hi, Firstly let me explain the problem, we have an a vb.net application which prints letters to a printer (either a local or remote printer). The application uses the Microsoft Word Object to...
0
by: funeeldy | last post by:
I need to locate a particular table in a document. I cannot hardcode the table number since it could be different in every doc. I do have some header text that comes right before it consistently,...
1
by: rlntemp-gns | last post by:
Re: Access 2003/Word 2003 I have about 100 motivational documents that I am wanting to import into a small database and put a front end on it that would allow the user to select one, read it and...
1
by: dittytwo | last post by:
Hi there The below code works if you don't try to do anything to the word document which is great (Not :D) I am having problems with the context command both text (i.e initial document with no...
5
by: sniipe | last post by:
Hi, I have a problem with unicode string in Pylons templates(Mako). I will print first char from my string encoded in UTF-8 and urllib.quote(), for example string 'Łukasz': ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.