Solved

Code working on break but freezing on run of it??

Posted on 2004-10-08
6
191 Views
Last Modified: 2010-05-02
Hello all.  I have a loop where I am printing documents.   On the break of the code the code works perfect and prints everything in the order I want.  When I full run it, the printer gets all these documents to he spooler quickly and they print all out of order.  So I added a line of code to wait until the background print completed before continuing and again it works perfect on the break of the code but it freezes on the full run without a break.  This problem is driving me nuts.  Can anyone help this is the code:

For xcount = 1 to 20
        xcount = xcount + 1
        ActiveDocument.PrintOut Range:=wdPrintFromTo, from:="1", To:=10
       
        Do While Application.BackgroundPrintingStatus > 0
        Loop

Next xcount
0
Comment
Question by:sbornstein2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12258998

Have you tried


Do While Application.BackgroundPrintingStatus > 0
doevents
       Loop
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 12259106
Why don't you simply set the BackGround argument to False ?

ActiveDocument.PrintOut Range:=wdPrintFromTo, from:="1", To:=10, Background:=False
0
 

Author Comment

by:sbornstein2
ID: 12260130
What would Background:=False do emoreau?  This is what is happening guys and it is driving me batty.  These documents that are going through the loop work fine until I add a "6th" attachment.  I know its hard to understand but what happens is the code loops through and then prints out a section of the word document.  The code I have up top is just a very scaled down version of it but its the same thing really.  After it gets to a 6th time through the loop that is when the Print Spooler no longer keeps things in order and the 6th time through the loop actually prints first.  I know confusing.  I am having the same exact problem in another Access application where I am launching Adobe and because I think it is out of process its printing all over the place and not in order.  If I can figure this out it might clue me in on that issue as well.  Its like I have to control the print queue and sometimes wait prior to printing the next document.  Thanks all for your time.  Really stuck on this one.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:sbornstein2
ID: 12260377
That was absolutly perfect and just what I needed emoreau.  You certainly know your stuff.  Thanks alot saved me alot of headache today at work.  I wish you could help me with the same type of issue however it is access launching a shell to a PDF document out of process and then it runs an access report.  I am having the same similar issue where the spool is printing all over the place.  So you know how to handle that within access when launching a shell waiting for the print to complete?  I can setup a new question. I think I have one out there under Access still open for good points actually.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 12260389
When BackGround is True, the PrintOut method starts to print your document and does't wait for your document to be completely printed before executing the next statement in your VB application.

0
 

Author Comment

by:sbornstein2
ID: 12260415
All I needed was the background property and I got rid of checking the status.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 90
Advice in Xamarin 21 118
VBA- How to change font, color and format in outlook e-mail sent from Access 2 156
Get the Y value of a line at X in a chart in VBA 28 67
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question