473,569 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

word 2003 - print marco

1 New Member
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 1528

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

Similar topics

4
4310
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
4110
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 this possible using the Printer object in Access? If not, is it possible any other way? Here is what I have tried but doesn't seem to work (letter...
5
4011
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 think - it might have been XP) to 2003. The database is impressive, both in what it does and the obtuse and inconsistent ways it works. There are...
4
2065
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 fine. If htey choose to "just print it" it seems ot ignore this command:
0
1059
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 generate the letters and print them (all of this is hidden from the user), this works fine on our development machines. However we have a site in...
0
3994
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, though. So, I tried to find that text, and then move to the next table. Then I need to add a row to the table which already has 4 columns. I need to...
1
2923
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 print it. Some of these original documents have bold formatting, a picture, and some italics. To try and preserve the original formatting would...
1
4370
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 text) or a subsequent addition of text, insert, to the document. as this is going to be used along side other com opened applications Excel power...
5
2363
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': ${urllib.unquote(c.user.firstName).encode('latin-1')} and I received this information:
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.