VBA and Timing

About the programming interface for the virtual PDF printer driver.

Moderator: jr

Post Reply
awardthemyth
Posts: 1
Joined: Fri Jun 08, 2007 12:42 pm

VBA and Timing

Post 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
Pliny
Posts: 5
Joined: Tue Jun 12, 2007 11:12 pm

Post 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
jr
Site Admin
Posts: 500
Joined: Sun Mar 26, 2006 12:28 pm

Post by jr »

Hi Pliny,

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

Best regards,
Jacob
cwany
Posts: 4
Joined: Fri Feb 29, 2008 10:51 am
Location: Poland
Contact:

Post by cwany »

i may have a dumb question, but i just can't find "runonce.ini" file nowhere... (after i run .WriteSettings)... any hint?
sjuric
Posts: 3
Joined: Sun Mar 09, 2008 6:33 pm

Post 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.
odekkers
Posts: 2
Joined: Wed Dec 05, 2007 3:48 pm

Post by odekkers »

Hello Sjuric,
Very interesting. Can you tell me how that call back functionality of BullZip works?
Post Reply