2
votes

We are using some OLE automation in Delphi 7 to open a word document, then once loaded, save it, and load it into a database.

This is working fine, but part of the requirement is to have a progress bar whilst the OLE bit is taking place, and also a timeout if the OLE part takes too long.

Problem we are having is that the entire GUI freezes whilst the OLE is taking place. The progress bar does nothing, then shoots up right at the end.

Any ideas on how we could approach this?

1
would using an own thread be an option?bummi

1 Answers

6
votes

I think this is going to be difficult to do cleanly. So far as I know, Word automation doesn't give you the opportunity to cancel long running events. It also doesn't notify you of progress.

Probably the best that you can do is first of all move the automation into a separate thread. Then throw up a marquee progress bar whilst the long running automation is in progress. At least that will let the user know that something is happening.

As far as cancelling goes, you can let the user cancel from your progress dialog and then have your program continue. You could kill the automation thread, but that would leave Word in a bad state. I'd just let it continue to completion, but then ignore the results. From the user's perspective this will meet your goals reasonably well, even if it's a little dirty behind the scenes.