473,666 Members | 1,991 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 2745
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...reducin g 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

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

Similar topics

2
3834
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 sure someone where will know how to do the following. We have a Word Template which is our standard contract type. I have some data stored my access database record. I want to merge the two together.
1
1568
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 that users are able to save documents through our application using word 2000 as the editor. I have written for word 2000 sothat the code works for other higher versions of word.
5
3329
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 = "P:\2004worksheets\IIS_WS.doc" Set oWord = New Word.Application oWord.Documents.Add (strObjectPath) oWord.PrintOut
8
3509
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 the moment the printed output is usually going to Word. It's turning into an unholy mess, because I'm having to prepare umpteen different Word templates, and the queries that drive them, depending on what events a course has.
1
4946
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 1. Query..I want to keep the fields seperatred. I do not want to sent on field with all accumulated languages from one person to Word. Each language should appear in the document in a separate cell Cross tables are not delivering the result I...
17
4195
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 won't be broken when my app is opened with those versions. Also is the Scripting Runtime included as part of the A2000 Runtime Engine which some of my customers use.
5
2171
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. Create a new C# ASP.NET web application named "demo" and modify Session_Start in Global.asax.cs as follows: protected void Session_Start(Object sender, EventArgs e) { Response.Write("Session_Start event fired at "+
1
7627
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 graph/chart within the report, once again from VB.NET. I have chosen to use Excel.Chart.8. So, to embed I do this from VB.NET: Dim theNewShape As InlineShape = m_Document.InlineShapes.AddOLEObject (ClassType:="Excel.Chart", _
8
14419
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", , , strWhere) and strWhere is a variable containg a list of key's for the report to print from a table. Is this possable to do? The reason for this is the person printing the report would like to do some editing of a memo field before...
0
8445
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8640
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5664
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2771
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.