473,507 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Microsoft Word (VBA Program printing problem)

Catalyst159
111 New Member
I have created a program in Word ( VBA) to print purchase orders, but the problem is when printing them since they print as one single spooled file per page, the Windows spooler sometimes prints them out of order. How could I go about resolving this. Any help or suggestions would be greatly appreciated. Thanks .
Jan 31 '08 #1
11 2735
daniel aristidou
491 Contributor
I have created a program in Word ( VBA) to print purchase orders, but the problem is when printing them since they print as one single spooled file per page, the Windows spooler sometimes prints them out of order. How could I go about resolving this. Any help or suggestions would be greatly appreciated. Thanks .
Well im not sure if this is the best advice....but i personally would of tried a timer...between pages...reducing the posibility of them being printed in wrong order.....since it wont print something that it hasn't yet recieved
Jan 31 '08 #2
WinblowsME
58 New Member
Try pausing between each print.

Expand|Select|Wrap|Line Numbers
  1. Sub Test
  2.    ' Code to print page 1
  3.    Call Pause(1)
  4.  
  5.    ' Code to print page 2
  6.    Call Pause(1)
  7.  
  8.    ' ...
  9. End Sub
  10.  
  11. Private Sub Pause(seconds As Double)
  12.    Dim start As Long
  13.  
  14.    start = Timer
  15.  
  16.    Do Until Timer - start >= seconds
  17.       DoEvents
  18.    Loop
  19. End Sub
Jan 31 '08 #3
Catalyst159
111 New Member
Is pause a function of vba
Jan 31 '08 #4
daniel aristidou
491 Contributor
Is pause a function of vba
Don't know....have you tried it?
Jan 31 '08 #5
Killer42
8,435 Recognized Expert Expert
No, Pause is a function that Winnie wrote, in the same message where it was used.
Feb 1 '08 #6
Killer42
8,435 Recognized Expert Expert
Note, you could also change the Windows print spooling settings. For instance, you can set it to begin printing immediately, rather than when the job is complete.
Feb 1 '08 #7
Catalyst159
111 New Member
Note, you could also change the Windows print spooling settings. For instance, you can set it to begin printing immediately, rather than when the job is complete.

How will this help the situation ?
Feb 1 '08 #8
daniel aristidou
491 Contributor
How will this help the situation ?
It will might make the printer read the pages in the right order....
Feb 1 '08 #9
Catalyst159
111 New Member
The print routine is something like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub PrintPO(d As Document)
  3.     Dim vBinNumbers As Variant
  4.     Dim vBinNames As Variant
  5.     Dim i As Integer
  6.  
  7.     Application.ActivePrinter = "po"
  8.     d.Repaginate
  9.  
  10.     'vBinNumbers = GetBinNumbers
  11.     'vBinNames = GetBinNames
  12.  
  13.     'MsgBox vBinNames(4)
  14.     'MsgBox vBinNumbers(4)
  15.     For i = 1 To d.BuiltInDocumentProperties(wdPropertyPages)
  16.         d.Content.Find.Execute FindText:="PURCHASE ORDER COPY 2 - DEPARTMENT KEEP", ReplaceWith:="PURCHASE ORDER COPY 1 - CLAIM FORM", Replace:=wdReplaceAll
  17.         d.PageSetup.FirstPageTray = 259     'Correct (Tray 2)
  18.         d.PageSetup.OtherPagesTray = 259    'Correct (Tray 2)
  19.         d.PrintOut Range:=wdPrintFromTo, From:=Str(i), To:=Str(i)
  20.         d.Content.Find.Execute FindText:="PURCHASE ORDER COPY 1 - CLAIM FORM", ReplaceWith:="PURCHASE ORDER COPY 2 - DEPARTMENT KEEP", Replace:=wdReplaceAll
  21.         d.PageSetup.FirstPageTray = 258     'Correct (Tray 3)
  22.         d.PageSetup.OtherPagesTray = 258    'Correct (Tray 3)
  23.         d.PrintOut Range:=wdPrintFromTo, From:=Str(i), To:=Str(i)
  24.     Next
  25.  
  26. End Sub
  27.  
  28.  

The problem is , occasionally the purchase orders print out of order. Am I missing something or doing something wrong somewhere.

Anyone, how do you think I can correct this.
Feb 1 '08 #10
Catalyst159
111 New Member
Does anyone have any ideas?
Feb 13 '08 #11
Killer42
8,435 Recognized Expert Expert
Well as far as I can see, you must be sending them in the wrong sequence. Because I don't see any way the spooler could jumble up the order of items within a single print file. If it got the file mixed up, you'd get garbage printed.

Perhaps you need to sort your records before printing them.
Feb 14 '08 #12

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

Similar topics

2
3825
by: JP SIngh | last post by:
HI All I just wonder if anyone has created a word document using ASP. I am able to create a work document with ASP without any problem but what I want to do is slightly more than I know. I am...
1
1560
by: Raju Joseph | last post by:
Hi All, I have a small problem at hand and am looking for suggestions. I have created a wrapper for word 2000 for our application which is in VB.NET 2003. Everything works fine in the sense...
5
3311
by: Stefania Scott | last post by:
I am trying to print a word document from Access. The code I've written works well in my computer but does not in the one were it is needed. Here the piece of code: 'doc path strObjectPath =...
8
3487
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
1
4913
by: svdh | last post by:
I have posed a question last saturday and have advanced alot in the meantime. But I am still not there Problem is that I try to merging various fields from various tables in one document in Word...
17
4178
by: Karl Irvin | last post by:
To use the Textstream object, I had to set a Reference to the Microsoft Scripting Runtime. This works good with A2000 Is the Scripting Runtime included with A2002 and A2003 so the Reference...
5
2163
by: Niklas Uhlin | last post by:
Someone please explain why Session_Start fires multiple times / retains SessionID values between sessions, when you open an ASP.NET page from MS Word. For details of the problem, see below: 1....
1
7615
by: Robin Tucker | last post by:
Heres and interesting problem: I have a VB.NET program that creates reports via. Word Automation. This all works fine. What I want to do as part of this report generation process is to embed a...
8
14407
by: ljungers | last post by:
Wondering if somone knows how to open a Access report in Word or export it to Word. Currently I'm opening and printing a report using VBA with the following command (DoCmd.OpenReport "TheReportName",...
0
7319
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
7376
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...
0
7485
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...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
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 ...
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.