Solved

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

Posted on 2004-10-08
6
186 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
  • 3
  • 2
6 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12258998

Have you tried


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

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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 69

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now