By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 2,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

Microsoft Word (VBA Program printing problem)

Catalyst159
100+
P: 111
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
Share this Question
Share on Google+
11 Replies


daniel aristidou
100+
P: 491
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

P: 58
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
100+
P: 111
Is pause a function of vba
Jan 31 '08 #4

daniel aristidou
100+
P: 491
Is pause a function of vba
Don't know....have you tried it?
Jan 31 '08 #5

Expert 5K+
P: 8,434
No, Pause is a function that Winnie wrote, in the same message where it was used.
Feb 1 '08 #6

Expert 5K+
P: 8,434
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
100+
P: 111
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
100+
P: 491
How will this help the situation ?
It will might make the printer read the pages in the right order....
Feb 1 '08 #9

Catalyst159
100+
P: 111
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
100+
P: 111
Does anyone have any ideas?
Feb 13 '08 #11

Expert 5K+
P: 8,434
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

Post your reply

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