Solved

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

Posted on 2004-10-08
6
187 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

896 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

16 Experts available now in Live!

Get 1:1 Help Now