Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pause Execution of VB application 1

Status
Not open for further replies.

nscheu

Technical User
Sep 10, 2001
10
0
0
US
I have a small VB application that retrieves a recordset of DocIds from a FileNet database. Using a loop the program prints the document(PDF) or each record through to the printer specified by the user. The code to print the document is:

RequestId = doc.DoPrint(idmPrintNative, Array(1, 100))

The problem I am having is that when there are numerous reocrds in the recordset I get a Acrobat error saying "There was an error opening the document".

I found out that I need to slow processing down to enable the documents to print correctly.

This was kinda of trial an error on how to do this. First i tried a DoEvents, and that didnt work, then I tried the Sleep API and that didnt work. Finally after being very frusterated I decided to pop up a msg box for every record. When the user clicks ok on the msgbox no matter how fast the document prints correctly. So what I have done, is open message boxes and then close them through a seris of API calls. The problem with this is that it is very slow and does not allow the user to do anything else with there machine while the application is running be/c the msgbox steals the focus.

Basically i don't know why the message box works and sleep or doevents does not. I have even tried opening and closing a Modal dialog programatically to trigger an event. I need something that does what the messagebox does with out having to open one and not have it take so much time.

Hopefully this does not confuse anyone, I have tried to make myself as clear as possible, if any further clarification is necessary please let me know. Thanks in advance.
 
I saw that link, and looks OK but too long.
Here is a shorter bit of code I use.
Let me know which one works better for you. Maybe I switch to that other one ;)

x44
I feed on feedback


Sub Pause()

Dim Pause, Start, Finish, TotalTime
Pause = 1.5 ' set pause to 1.5 seconds

Do
Start = timer ' Set start time.

DoEvents ' Yield to other processes.
Loop Until timer > Start + Pause 'loop runs 1.5 sec
Finish = timer ' Set end time.

End Sub
 
They both work! Thanks, but I really dont see what is differant about that code then anything else I have tried. Oh well. Thanks Again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top