Group:  Microsoft Word ยป microsoft.public.word.oleinterop
Thread: Suppressing popup message boxes when using Word via ole

Geek News

Suppressing popup message boxes when using Word via ole
Carl 4/27/2007 3:16:02 PM
Greetings -

Using Word 2003 on Windows XP Pro SP2, 512MB system memory.

I have a tool written in C#.NET that uses the ole interface in Word to
process several hundred Word documents. The process is:

Open a document.
TheDoc.TrackRevisions = false;
TheDoc.AcceptAllRevisions ();
SaveAs XML.
Close the document, discarding changes.

Then do a bunch of processing on the XML form of the document.

This process has worked well for a couple of years, but now some few of
these hundreds of documents have enough tracked changes that it look like the
AcceptAllRevisions call causes a message box to be presented warning that
Word does not have sufficient memory and the operation will not be able to be
undone, do I want to continue?

This message box causes a problem, because this is an automated process
running as a scheduled task in the wee hours and there is nobody there to say
Yes, continue.

Is there some way to suppress this message, or force a Yes answer? Or some
other work-around to allow the process to continue? In this circumstance we
always want to say yes, go ahead we do not want to undo.

I've seen some references around talking about clearing the Undo cache, but
since this appears to be happening as a result of the single call to
AcceptAllRevisions, I'm not sure how to proceed.

Any ideas will be most appreciated.

--
regards - carl

Re: Suppressing popup message boxes when using Word via ole
"Shauna Kelly" <ShaunaKelly[ at ]SendNoSpamToShaunaKelly.com> 4/28/2007 10:08:50 AM
Hi Carl

In a case such as yours, I would clear the undo buffer regularly, perhaps
each time you close a file after processing. You can use
ActiveDocument.UndoClear to clear the buffer.

Word.Application.DisplayAlerts = wdAlertsNone will suppress the display of
lots of Word's alerts, but not all. Whether it works on the particular
message you're seeing, I can't say, not least because I can't reproduce the
problem!

Make sure you reinstate alerts with Word.Application.DisplayAlerts =
wdAlertsAll at the end of your code.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"Carl" <Carl[ at ]discussions.microsoft.com> wrote in message
news:D667478E-84C8-408F-961B-B8880D787B65[ at ]microsoft.com...
[Quoted Text]
> Greetings -
>
> Using Word 2003 on Windows XP Pro SP2, 512MB system memory.
>
> I have a tool written in C#.NET that uses the ole interface in Word to
> process several hundred Word documents. The process is:
>
> Open a document.
> TheDoc.TrackRevisions = false;
> TheDoc.AcceptAllRevisions ();
> SaveAs XML.
> Close the document, discarding changes.
>
> Then do a bunch of processing on the XML form of the document.
>
> This process has worked well for a couple of years, but now some few of
> these hundreds of documents have enough tracked changes that it look like
> the
> AcceptAllRevisions call causes a message box to be presented warning that
> Word does not have sufficient memory and the operation will not be able to
> be
> undone, do I want to continue?
>
> This message box causes a problem, because this is an automated process
> running as a scheduled task in the wee hours and there is nobody there to
> say
> Yes, continue.
>
> Is there some way to suppress this message, or force a Yes answer? Or some
> other work-around to allow the process to continue? In this circumstance
> we
> always want to say yes, go ahead we do not want to undo.
>
> I've seen some references around talking about clearing the Undo cache,
> but
> since this appears to be happening as a result of the single call to
> AcceptAllRevisions, I'm not sure how to proceed.
>
> Any ideas will be most appreciated.
>
> --
> regards - carl
>


Re: Suppressing popup message boxes when using Word via ole
Carl 5/2/2007 2:06:10 PM
Hi Shauna...

Many thanks for your answer, I appreciate the help.

I have narrowed it down to one particular document that is the problem
child... a fairly large one, with lots of pictures and so on. This document
has 2300 revisions.

Word itself is closed between processing of each document. I'm assuming that
closing the app as a whole, instead of closing just the document will flush
the undo buffer.

I have tried the DisplayAlerts being set to wdAlertsNone, but that does not
suppress this particular message (thanks for the tip, though).

I also tried accepting revisions one at a time in a loop and flushing the
undo buffer every three revisions or so. Sadly, this does not work either, as
Word appears to hang up on one of the accept calls part way through the
document, and never returns (I've left it running for > 1 hour in testing) so
this scheme does not work, either.


--
regards - carl



"Shauna Kelly" wrote:

[Quoted Text]
> Hi Carl
>
> In a case such as yours, I would clear the undo buffer regularly, perhaps
> each time you close a file after processing. You can use
> ActiveDocument.UndoClear to clear the buffer.
>
> Word.Application.DisplayAlerts = wdAlertsNone will suppress the display of
> lots of Word's alerts, but not all. Whether it works on the particular
> message you're seeing, I can't say, not least because I can't reproduce the
> problem!
>
> Make sure you reinstate alerts with Word.Application.DisplayAlerts =
> wdAlertsAll at the end of your code.
>
> Hope this helps.
>
> Shauna Kelly. Microsoft MVP.
> http://www.shaunakelly.com/word
>
>
> "Carl" <Carl[ at ]discussions.microsoft.com> wrote in message
> news:D667478E-84C8-408F-961B-B8880D787B65[ at ]microsoft.com...
> > Greetings -
> >
> > Using Word 2003 on Windows XP Pro SP2, 512MB system memory.
> >
> > I have a tool written in C#.NET that uses the ole interface in Word to
> > process several hundred Word documents. The process is:
> >
> > Open a document.
> > TheDoc.TrackRevisions = false;
> > TheDoc.AcceptAllRevisions ();
> > SaveAs XML.
> > Close the document, discarding changes.
> >
> > Then do a bunch of processing on the XML form of the document.
> >
> > This process has worked well for a couple of years, but now some few of
> > these hundreds of documents have enough tracked changes that it look like
> > the
> > AcceptAllRevisions call causes a message box to be presented warning that
> > Word does not have sufficient memory and the operation will not be able to
> > be
> > undone, do I want to continue?
> >
> > This message box causes a problem, because this is an automated process
> > running as a scheduled task in the wee hours and there is nobody there to
> > say
> > Yes, continue.
> >
> > Is there some way to suppress this message, or force a Yes answer? Or some
> > other work-around to allow the process to continue? In this circumstance
> > we
> > always want to say yes, go ahead we do not want to undo.
> >
> > I've seen some references around talking about clearing the Undo cache,
> > but
> > since this appears to be happening as a result of the single call to
> > AcceptAllRevisions, I'm not sure how to proceed.
> >
> > Any ideas will be most appreciated.
> >
> > --
> > regards - carl
> >
>
>
>
Re: Suppressing popup message boxes when using Word via ole
"Shauna Kelly" <ShaunaKelly[ at ]SendNoSpamToShaunaKelly.com> 5/6/2007 11:16:55 PM
Hi Carl

The Revisions collection is buggy.

Don't try cycling through the collection with For Each. Instead, try always
accepting Revisions(1) until there aren't any more revisions.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"Carl" <Carl[ at ]discussions.microsoft.com> wrote in message
news:56101AEB-C653-4335-90FE-8921A3112E95[ at ]microsoft.com...
[Quoted Text]
> Hi Shauna...
>
> Many thanks for your answer, I appreciate the help.
>
> I have narrowed it down to one particular document that is the problem
> child... a fairly large one, with lots of pictures and so on. This
> document
> has 2300 revisions.
>
> Word itself is closed between processing of each document. I'm assuming
> that
> closing the app as a whole, instead of closing just the document will
> flush
> the undo buffer.
>
> I have tried the DisplayAlerts being set to wdAlertsNone, but that does
> not
> suppress this particular message (thanks for the tip, though).
>
> I also tried accepting revisions one at a time in a loop and flushing the
> undo buffer every three revisions or so. Sadly, this does not work either,
> as
> Word appears to hang up on one of the accept calls part way through the
> document, and never returns (I've left it running for > 1 hour in testing)
> so
> this scheme does not work, either.
>
>
> --
> regards - carl
>
>
>
> "Shauna Kelly" wrote:
>
>> Hi Carl
>>
>> In a case such as yours, I would clear the undo buffer regularly, perhaps
>> each time you close a file after processing. You can use
>> ActiveDocument.UndoClear to clear the buffer.
>>
>> Word.Application.DisplayAlerts = wdAlertsNone will suppress the display
>> of
>> lots of Word's alerts, but not all. Whether it works on the particular
>> message you're seeing, I can't say, not least because I can't reproduce
>> the
>> problem!
>>
>> Make sure you reinstate alerts with Word.Application.DisplayAlerts =
>> wdAlertsAll at the end of your code.
>>
>> Hope this helps.
>>
>> Shauna Kelly. Microsoft MVP.
>> http://www.shaunakelly.com/word
>>
>>
>> "Carl" <Carl[ at ]discussions.microsoft.com> wrote in message
>> news:D667478E-84C8-408F-961B-B8880D787B65[ at ]microsoft.com...
>> > Greetings -
>> >
>> > Using Word 2003 on Windows XP Pro SP2, 512MB system memory.
>> >
>> > I have a tool written in C#.NET that uses the ole interface in Word to
>> > process several hundred Word documents. The process is:
>> >
>> > Open a document.
>> > TheDoc.TrackRevisions = false;
>> > TheDoc.AcceptAllRevisions ();
>> > SaveAs XML.
>> > Close the document, discarding changes.
>> >
>> > Then do a bunch of processing on the XML form of the document.
>> >
>> > This process has worked well for a couple of years, but now some few of
>> > these hundreds of documents have enough tracked changes that it look
>> > like
>> > the
>> > AcceptAllRevisions call causes a message box to be presented warning
>> > that
>> > Word does not have sufficient memory and the operation will not be able
>> > to
>> > be
>> > undone, do I want to continue?
>> >
>> > This message box causes a problem, because this is an automated process
>> > running as a scheduled task in the wee hours and there is nobody there
>> > to
>> > say
>> > Yes, continue.
>> >
>> > Is there some way to suppress this message, or force a Yes answer? Or
>> > some
>> > other work-around to allow the process to continue? In this
>> > circumstance
>> > we
>> > always want to say yes, go ahead we do not want to undo.
>> >
>> > I've seen some references around talking about clearing the Undo cache,
>> > but
>> > since this appears to be happening as a result of the single call to
>> > AcceptAllRevisions, I'm not sure how to proceed.
>> >
>> > Any ideas will be most appreciated.
>> >
>> > --
>> > regards - carl
>> >
>>
>>
>>


Re: Suppressing popup message boxes when using Word via ole
Carl 5/7/2007 5:04:02 PM
Well, at least I know I was on the right track... :)

Thanks once again, Shauna -

I had the loop set up as you suggest here... as long as the Revisions Count
is > 0 accept Revision 1. The Accept call itself hangs somewhere along the
line, and not on the last one.

I'm currently working around this by ignoring this particular document. The
team that owns it is aware of the problem and has committed to doing a manual
review of revisions and getting them all accepted, which should fix the
problem.

I appreciate your help...

--
regards - carl



"Shauna Kelly" wrote:

[Quoted Text]
> Hi Carl
>
> The Revisions collection is buggy.
>
> Don't try cycling through the collection with For Each. Instead, try always
> accepting Revisions(1) until there aren't any more revisions.
>
> Hope this helps.
>
> Shauna Kelly. Microsoft MVP.
> http://www.shaunakelly.com/word
>
>
> "Carl" <Carl[ at ]discussions.microsoft.com> wrote in message
> news:56101AEB-C653-4335-90FE-8921A3112E95[ at ]microsoft.com...
> > Hi Shauna...
> >
> > Many thanks for your answer, I appreciate the help.
> >
> > I have narrowed it down to one particular document that is the problem
> > child... a fairly large one, with lots of pictures and so on. This
> > document
> > has 2300 revisions.
> >
> > Word itself is closed between processing of each document. I'm assuming
> > that
> > closing the app as a whole, instead of closing just the document will
> > flush
> > the undo buffer.
> >
> > I have tried the DisplayAlerts being set to wdAlertsNone, but that does
> > not
> > suppress this particular message (thanks for the tip, though).
> >
> > I also tried accepting revisions one at a time in a loop and flushing the
> > undo buffer every three revisions or so. Sadly, this does not work either,
> > as
> > Word appears to hang up on one of the accept calls part way through the
> > document, and never returns (I've left it running for > 1 hour in testing)
> > so
> > this scheme does not work, either.
> >
> >
> > --
> > regards - carl
> >
> >
> >
> > "Shauna Kelly" wrote:
> >
> >> Hi Carl
> >>
> >> In a case such as yours, I would clear the undo buffer regularly, perhaps
> >> each time you close a file after processing. You can use
> >> ActiveDocument.UndoClear to clear the buffer.
> >>
> >> Word.Application.DisplayAlerts = wdAlertsNone will suppress the display
> >> of
> >> lots of Word's alerts, but not all. Whether it works on the particular
> >> message you're seeing, I can't say, not least because I can't reproduce
> >> the
> >> problem!
> >>
> >> Make sure you reinstate alerts with Word.Application.DisplayAlerts =
> >> wdAlertsAll at the end of your code.
> >>
> >> Hope this helps.
> >>
> >> Shauna Kelly. Microsoft MVP.
> >> http://www.shaunakelly.com/word
> >>
> >>
> >> "Carl" <Carl[ at ]discussions.microsoft.com> wrote in message
> >> news:D667478E-84C8-408F-961B-B8880D787B65[ at ]microsoft.com...
> >> > Greetings -
> >> >
> >> > Using Word 2003 on Windows XP Pro SP2, 512MB system memory.
> >> >
> >> > I have a tool written in C#.NET that uses the ole interface in Word to
> >> > process several hundred Word documents. The process is:
> >> >
> >> > Open a document.
> >> > TheDoc.TrackRevisions = false;
> >> > TheDoc.AcceptAllRevisions ();
> >> > SaveAs XML.
> >> > Close the document, discarding changes.
> >> >
> >> > Then do a bunch of processing on the XML form of the document.
> >> >
> >> > This process has worked well for a couple of years, but now some few of
> >> > these hundreds of documents have enough tracked changes that it look
> >> > like
> >> > the
> >> > AcceptAllRevisions call causes a message box to be presented warning
> >> > that
> >> > Word does not have sufficient memory and the operation will not be able
> >> > to
> >> > be
> >> > undone, do I want to continue?
> >> >
> >> > This message box causes a problem, because this is an automated process
> >> > running as a scheduled task in the wee hours and there is nobody there
> >> > to
> >> > say
> >> > Yes, continue.
> >> >
> >> > Is there some way to suppress this message, or force a Yes answer? Or
> >> > some
> >> > other work-around to allow the process to continue? In this
> >> > circumstance
> >> > we
> >> > always want to say yes, go ahead we do not want to undo.
> >> >
> >> > I've seen some references around talking about clearing the Undo cache,
> >> > but
> >> > since this appears to be happening as a result of the single call to
> >> > AcceptAllRevisions, I'm not sure how to proceed.
> >> >
> >> > Any ideas will be most appreciated.
> >> >
> >> > --
> >> > regards - carl
> >> >
> >>
> >>
> >>
>
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net