VBA and Timing
Posted: Fri Jun 08, 2007 1:09 pm
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
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