how to wait for completion of print-to-pdf, filecopy, kill? | | |
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 | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
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. | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
<<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 resource@pcdatasheet.com www.pcdatasheet.com
<cantelow@csd.net> wrote in message
news:1109178759.314168.145600@z14g2000cwz.googlegr oups.com...[color=blue]
> 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
>[/color] | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
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 | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
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 resource@pcdatasheet.com www.pcdatasheet.com
<cantelow@csd.net> wrote in message
news:1109187679.474304.131670@l41g2000cwc.googlegr oups.com...[color=blue]
> 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
>[/color] | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
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 | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
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 | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
On 23 Feb 2005 15:46:44 -0800, cantelow@csd.net wrote:
[color=blue]
>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[/color]
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
.... | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
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 | | | | re: how to wait for completion of print-to-pdf, filecopy, kill?
On 3 Mar 2005 14:30:59 -0800, cantelow@csd.net wrote:
[color=blue]
>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[/color]
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
.... |  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|