By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

how to wait for completion of print-to-pdf, filecopy, kill?

P: n/a
Hi. I've got a program printing multiple pdf reports, and I need to
wait for completion of various associated operations- The pdf printer
prints to one file, then I need to copy that where I need it, then
delete the old file, repeat with the next report. I need to wait for
each step to complete or I get errors due to the previous thing being
open and not done yet.

Is there any elegant way to do that? My FileCopy in particular has
problems. I set up a goto error loop to catch an error due to an open
file, do an api sleep for a second or two, and try again- but it
appears to pass by the loop before it's really done somehow, and I get
a permission error anyway.

Any input or pointers to where to look is welcome, thanks a bunch.

-Ann

Nov 13 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
You may need to add a few DoEvents commands to force the application to
complete one task before starting another. If you put them
immmediately after a statement that seems to be causing your problems
that should solve that one. Add one at at time and see if that helps
you get further in your processes.

Nov 13 '05 #2

P: n/a
<<The pdf printer prints to one file, then I need to copy that where I need
it, then delete the old file, repeat with the next report. >>

Put all these processes in a function and put the function in a loop where
you feed in all the parameters. Access will execute everything in a function
before moving on to succeeding code (in this case the next report).

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
<ca******@csd.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi. I've got a program printing multiple pdf reports, and I need to
wait for completion of various associated operations- The pdf printer
prints to one file, then I need to copy that where I need it, then
delete the old file, repeat with the next report. I need to wait for
each step to complete or I get errors due to the previous thing being
open and not done yet.

Is there any elegant way to do that? My FileCopy in particular has
problems. I set up a goto error loop to catch an error due to an open
file, do an api sleep for a second or two, and try again- but it
appears to pass by the loop before it's really done somehow, and I get
a permission error anyway.

Any input or pointers to where to look is welcome, thanks a bunch.

-Ann

Nov 13 '05 #3

P: n/a
Thanks very much for the suggestions. DoEvents didn't seem to affect
anything, my code still proceeded before the report was done with its
async printing to a pdf file.

I was intrigued with the thought that I could put the report open in a
separate function, but that didn't work for me, either. The report,
opened from a separate function in a separate library, was still
printing, my filecopy command after the function came back took it
early, and wound up with an empty pdf file after copy in the copy
destination.

I was wrong about where the fail was, it is that the report print is
not completed before a subsequent filecopy tries to get hold of it and
copy it to a new location. I'll update you with anything I find. I
may just have to introduce X seconds of wait time in between reports
and hope to guess a good value for that. This is what the DoEvents
documentation says to do.

Thanks again,
Ann

Nov 13 '05 #4

P: n/a
Try putting the open report and print to PDF in a function and then do the
filecopy and kill outside the function. Include all this in the loop to do
multiple reports.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
<ca******@csd.net> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Thanks very much for the suggestions. DoEvents didn't seem to affect
anything, my code still proceeded before the report was done with its
async printing to a pdf file.

I was intrigued with the thought that I could put the report open in a
separate function, but that didn't work for me, either. The report,
opened from a separate function in a separate library, was still
printing, my filecopy command after the function came back took it
early, and wound up with an empty pdf file after copy in the copy
destination.

I was wrong about where the fail was, it is that the report print is
not completed before a subsequent filecopy tries to get hold of it and
copy it to a new location. I'll update you with anything I find. I
may just have to introduce X seconds of wait time in between reports
and hope to guess a good value for that. This is what the DoEvents
documentation says to do.

Thanks again,
Ann

Nov 13 '05 #5

P: n/a
Thanks. No, no luck with putting the pdf in a separate function. I
tried putting the function in the local module instead of a separate
library, still no success.

I also tried writing a text file during the report Close event, but the
text file appears before the pdf file even begins to write.

However, I see that the pdf driver creator, pdf995, has a relevant
question in their developer faq at http://www.pdf995.com/faq_dev.html,
titled "How do I use a ProcessPDF handler to programmatically determine
when a pdf is complete?". This has some code examples concerning
updating a pdf995-specific ini file, with the name of an application
that pdf995 will run when it is finished printing. This seems the
proper way to do it, though it locks us in to the pdf995 printer
driver, something I hoped to avoid. It's rather over my head, but
there is example code there that I will try.

Best,
Ann

Nov 13 '05 #6

P: n/a
Hi. I found some further help here:
http://www.freeware995.com/misc/vbacode.txt. This code was
specifically tailored for ms access. I made a few adjustments for my
situation, e.g. I don't need to reset the ini files in between every
report, but the code is solid, worked for me on a test run of 20-30
reports on a slow machine. I'm a happy camper. The code is
unattributed, but I'm grateful to whoever wrote it.

In summary, I abandoned the approach of using FileCopy to copy the pdf
report from a single pre-configured pdf report name, and instead
configured the different report names from within my program by
updating the pdf995 ini files, and printed directly to them that way.

There's also some wait checking code in this pdfwrite example that I
have left in with reduced times. I don't know if it's needed, but I
think it might be quite important.

Best,
Ann

Nov 13 '05 #7

P: n/a
On 23 Feb 2005 15:46:44 -0800, ca******@csd.net wrote:
Hi. I found some further help here:
http://www.freeware995.com/misc/vbacode.txt. This code was
specifically tailored for ms access. I made a few adjustments for my
situation, e.g. I don't need to reset the ini files in between every
report, but the code is solid, worked for me on a test run of 20-30
reports on a slow machine. I'm a happy camper. The code is
unattributed, but I'm grateful to whoever wrote it.

In summary, I abandoned the approach of using FileCopy to copy the pdf
report from a single pre-configured pdf report name, and instead
configured the different report names from within my program by
updating the pdf995 ini files, and printed directly to them that way.

There's also some wait checking code in this pdfwrite example that I
have left in with reduced times. I don't know if it's needed, but I
think it might be quite important.

Best,
Ann

Is it necessary for PDF995 to access the internet in order to print the report?
If I buy the key, will the program no longer try to access the internet?

Chuck
....
Nov 13 '05 #8

P: n/a
That's right, Chuck. It works quietly without loading IExplorer after
you buy and install the key. I found it's a good idea to figure out
whether the suite key is needed before buying- I needed the $19.95
pdfedit key as well as pdf995 for my code interface. If you get the
pdfedit key, the pdf995 app is also paid for.

Ann

Nov 13 '05 #9

P: n/a
On 3 Mar 2005 14:30:59 -0800, ca******@csd.net wrote:
That's right, Chuck. It works quietly without loading IExplorer after
you buy and install the key. I found it's a good idea to figure out
whether the suite key is needed before buying- I needed the $19.95
pdfedit key as well as pdf995 for my code interface. If you get the
pdfedit key, the pdf995 app is also paid for.

Ann

Thanks for the reply. $19.95 is perfectly acceptable. I just didn't want to
buy the key only to find out that the program still wanted to access the
internet.

Chuck
....
Nov 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.