how to realize an abort-button?

B

b.schmidt

hi,

I have an add-in with a custom task pane in Word 2007, where I import
the recipients for a mail merge. Unfortunately the whole application
freezes, when I import many contacts (>1000), so it's impossible to
click on an abort-button.

Does anyone know a good way, how to realize an abort-button? I tried
running the add-in as a different thread, but then I always get errors.

Can someone help me?

best regards,
bernhard
 
J

Jean-Guy Marcil

b.schmidt was telling us:
b.schmidt nous racontait que :
hi,

I have an add-in with a custom task pane in Word 2007, where I import
the recipients for a mail merge. Unfortunately the whole application
freezes, when I import many contacts (>1000), so it's impossible to
click on an abort-button.

Does anyone know a good way, how to realize an abort-button? I tried
running the add-in as a different thread, but then I always get
errors.
Can someone help me?

If you know the cause of the problem, prevent it from happening in the first
place.

Count the records before you do the merge.
If the number of records is higher than what is safe, warn the user that the
merge cannot happen until they refine/limit the merge in some way.
Or actually perform two (or more) separate merges until all the records have
been processed.

No need of an abort button, which, in my humble opinion, would be bad coding
in this case as it seems that the whole problem can be averted, unless you
re not telling us the whole story! In which case, please do so that we can
offer other alternatives.


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
B

b.schmidt

Jean-Guy Marcil, am 22.05.2007 17:31:
If you know the cause of the problem, prevent it from happening in the first
place.

Count the records before you do the merge.
If the number of records is higher than what is safe, warn the user that the
merge cannot happen until they refine/limit the merge in some way.
Or actually perform two (or more) separate merges until all the records have
been processed.

No need of an abort button, which, in my humble opinion, would be bad coding
in this case as it seems that the whole problem can be averted, unless you
re not telling us the whole story! In which case, please do so that we can
offer other alternatives.

Many recipients = long waiting time. This isn't bad coding, the import
is done in less than a minute even with 1000 contacts, I'm just thinking
of the worst case. I don't think the customer will like the fact, that
there is no possibility to abort the import.

Neither refining/limit the merge nor performing seperate merges are
acceptable solutions.

Anyway, all I wanted to know: Is it possible to make an abort-button and
if so, how?
Or at least run the add-in in a different thread, so that Word doesn't
freeze completely?

Thanks,
Bernhard
 
J

Jean-Guy Marcil

b.schmidt was telling us:
b.schmidt nous racontait que :
Jean-Guy Marcil, am 22.05.2007 17:31:

Many recipients = long waiting time. This isn't bad coding, the import
is done in less than a minute even with 1000 contacts, I'm just
thinking of the worst case. I don't think the customer will like the
fact, that there is no possibility to abort the import.

Neither refining/limit the merge nor performing seperate merges are
acceptable solutions.

Anyway, all I wanted to know: Is it possible to make an abort-button
and if so, how?
Or at least run the add-in in a different thread, so that Word doesn't
freeze completely?

Sorry, in your first post you wrote that you had experienced crashes,
therefore the problem is predictable and observable. In such cases I believe
you have to code against making such crashes happen. Now you seem to be
stating that the problem is hypothetical, in this case I see the potential
for an "Abort" type of button.

Anyway, if you launch the merge process from the active document I do not
think you can use a different thread.
You could launch a new Word instance which I believe is in a different
thread.

For instance:

Dim appWord As Word.Application
Dim docNew As Word.Document

Set appWord = New Word.Application
Set docNew = appWord.Documents.Add
appWord.Visible = True

used from Word will create a new Word instance that can be quit or aborted
without affecting the instance that created it. But I have not tested what
happens when this new instance crashes. Does it make the first one crash as
well? If not, then your abort button would only need

appWord.Quit


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
B

b.schmidt

Sorry, in your first post you wrote that you had experienced crashes,
therefore the problem is predictable and observable. In such cases I
believe you have to code against making such crashes happen. Now you
seem to be stating that the problem is hypothetical, in this case I
see the potential for an "Abort" type of button.

Oh sorry, then this was a misunderstanding. When I wrote that "Word
freezes" I didn't mean it "crashes", I mean it's just frozen for the
time the import is running. Once the import is done, everything is ok.
Anyway, if you launch the merge process from the active document I do
not think you can use a different thread.
You could launch a new Word instance which I believe is in a different
thread.

According the new application instance: As I said I have a custom task
pane in Word, so the Word application is already open. I can't use a
different one, because the import happens in the add-in and attaches the
DataSource to the current document. I'd rather have to split off the
add-in somehow. My first guess would have been threads, but apparently
it's not possible to run the add-in as a different thread...

btw: I'm opening an Outlook application when doing the import with

Outlook.ApplicationClass olApp = new Outlook.Application();

This works fine, and when I use olApp.Quit() the application closes. But
when I already have an open Outlook window, the olApp.Quit() causes this
one to close too, so I can't use this method at the moment.
Maybe it's the same with Word too... :/

best regards,
bernhard


Jean-Guy Marcil, am 23.05.2007 13:02:
 
B

b.schmidt

Sorry, in your first post you wrote that you had experienced crashes,
therefore the problem is predictable and observable. In such cases I
believe you have to code against making such crashes happen. Now you
seem to be stating that the problem is hypothetical, in this case I
see the potential for an "Abort" type of button.

Oh sorry, then this was a misunderstanding. When I wrote that "Word
freezes" I didn't mean it "crashes", I mean it's just frozen for the
time the import is running. Once the import is done, everything is ok.
Anyway, if you launch the merge process from the active document I do
not think you can use a different thread.
You could launch a new Word instance which I believe is in a different
thread.

According the new application instance: As I said I have a custom task
pane in Word, so the Word application is already open. I can't use a
different one, because the import happens in the add-in and attaches the
DataSource to the current document. I'd rather have to split off the
add-in somehow. My first guess would have been threads, but apparently
it's not possible to run the add-in as a different thread...

btw: I'm opening an Outlook application when doing the import with

Outlook.Application olApp = new Outlook.Application();

This works fine, and when I use olApp.Quit() the application closes. But
when I already have an open Outlook window, the olApp.Quit() causes this
one to close too, so I can't use this method at the moment.
Maybe it's the same with Word too... :/

best regards,
bernhard

Jean-Guy Marcil, am 23.05.2007 13:02:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top