Solved

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

Posted on 2004-10-08
6
188 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 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…

813 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

15 Experts available now in Live!

Get 1:1 Help Now