[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-10-08
6
Medium Priority
?
198 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 200 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 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…
Suggested Courses

873 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