Page 1 of 1

VBA and Timing

Posted: Fri Jun 08, 2007 1:09 pm
by awardthemyth
Hi

I am testing some batch PDF creation with Bullzip using Microsoft Access 2003 on Vista. Here is the main bit of code I am using:

iCounter = 20000

Do Until icounter = 20040
sSleep 2000 'milliseconds
myobject.SetValue "output", sDir & "\" & iCounter & ".pdf"
myobject.SetValue "showsettings", "never"
myobject.SetValue "showpdf", "no"
myobject.WriteSettings (True) 'writes the settings in a runonce.ini that it immediately deleted after being used.

DoCmd.OpenReport "CCSSitesByRegionAndCity", , , "ID = " & iCounter
iCounter = iCounter + 1

Loop

As you can see I have had to put a 2 second sleep in before writing the runonce.ini. Without the sleep I would get the bullzip save file dialog pop up for various iterations of the loop, and often an error message saying that it could not write to runonce.ini because it was locked.

I assume that this is because of a timing issue between runonce.ini getting written, Bullzip printing the document using the file and the file getting deleted after printing is completed ie. while the printer is still printing the last iteration, the code writes the runonce for the new iteration, but as the printing of the previous iteration finishes it deletes the new file.

Is there a way of using the API so that it waits to write the Runonce.ini until the current print action has completed?

Thanks

Matthew

Posted: Wed Jun 13, 2007 7:33 pm
by Pliny
Hi -

As I mentioned in my posting under "COM Interface for Print Job Status", use FileSystemObjects FileExists, but this time on the runonce.ini file. Instead of a counter, just loop while runonce.ini exists....

Dim fso as new FileSystemObject

while fso.FileExists(<Path>"\runonce.ini")
wend

myobject.SetValue "output", sDir & "\" & iCounter & ".pdf"
myobject.SetValue "showsettings", "never"
myobject.SetValue "showpdf", "no"
myobject.WriteSettings (True) 'writes the settings in a runonce.ini that it immediately deleted after being used.

etc,etc....

This will positively hold up processing until runonce.ini is deleted from the last run.

Pliny

Posted: Thu Jun 14, 2007 9:36 am
by jr
Hi Pliny,

It sounds like a good workaround. Keep us posted with your findings.

Best regards,
Jacob

Posted: Fri Feb 29, 2008 11:53 am
by cwany
i may have a dumb question, but i just can't find "runonce.ini" file nowhere... (after i run .WriteSettings)... any hint?

Posted: Sun Mar 09, 2008 6:59 pm
by sjuric
I found out that none of this solutions are 100%. Try and run some test scenarios - generate some various numbers of pdf documents. I can guarantee that there will be synhronization issues and some dialogs will popup.

The resolution is very simple - use the callback functionality that BullZip PDF printer supports, when the printer finishes a job you get a callback (eihter success or error or both) and after that you progress to anonther print job.

Posted: Thu Apr 10, 2008 3:11 pm
by odekkers
Hello Sjuric,
Very interesting. Can you tell me how that call back functionality of BullZip works?