From: Nigel Bufton on
Thanks, I'll try it.

Nigel

"alborg" <alborg(a)discussions.microsoft.com> wrote in message
news:4A598D8E-2FEF-450B-A363-49AA60FA3AD2(a)microsoft.com...
> Ooops- one error in your version of the code that I listed:
>
> Convert "appWord.Quit" to "appWord.Application.Quit" since in this case
> appWord was declared as an object ("Dim appWord As Object")-
> '-------------------------------------------------------
> Private Sub Document_Close()
> On Error GoTo Err_GoToWord_Click
> Dim appWord As Object 'or Word.Application
> Dim Wordwasnotrunning As Boolean ' Flag for final release.
> On Error Resume Next
> Repeat:
> Set appWord = GetObject(, "Word.Application")
> AppActivate "Microsoft Word"
> If err = 0 Then
> 'Word is still running
> Wordwasnotrunning = True
> appWord.Application.Quit
> Set appword = Nothing
> GoTo Repeat
> End If
> End Sub
> '-------------------------------------------------------
> Cheers,
> Al
>
> "Nigel Bufton" wrote:
>
>> > "Nigel Bufton" <nigel(a)bufton.org> wrote in message
>> > news:uz#Bd0ifKHA.2596(a)TK2MSFTNGP04.phx.gbl...
>> >> My application pushes Word to the limit. It can produce documents
>> >> that
>> >> are hundreds of pages long including many pictures and many shapes
>> >> (lines, rectangles) to create charts. With a large document, Word
>> >> will
>> >> "crash" (cease to process any more directives) with "memory or disk
>> >> problem".
>> >>
>> >> Because the documents are created with many sections, the application
>> >> saves the document at the end of each section.
>> >>
>> >> It error traps Word crashing, at which point I need it to quit Word
>> >> and
>> >> start it afresh - resuming from the start of the section in which it
>> >> crashed.
>> >>
>> >> All of the logic works fine, except in many cases a Quit or Close
>> >> directive fails because Word has reached the end of its tether.
>> >>
>> >> Is there a simple way to close the crashed instance of Word, or do I
>> >> need
>> >> to use the Windows API to kill the WinWord process. If so, is there
>> >> any
>> >> easy way of determining which is the process in question if there are
>> >> more than one WinWord process running?
>> >>
>> >> Thanks for any guidance.
>> >>
>> >> Nigel
>> >
>> "Doug Robbins - Word MVP" <dkr(a)REMOVECAPSmvps.org> wrote in message
>> news:CB015346-3E82-4FDF-A8A0-276598C1B8F5(a)microsoft.com...
>> > Do you have
>> >
>> > [documentobject].UndoClear
>> >
>> > in your code anywhere. If not, I would insert that after each section
>> > is
>> > saved and see if it makes any difference.
>> >
>> > --
>> > Hope this helps.
>> >
>> > Please reply to the newsgroup unless you wish to avail yourself of my
>> > services on a paid consulting basis.
>> >
>> > Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>> >
>>
>> Yes, I have UndoClear after each save. The complexity of the very
>> large
>> documents will inevitably cause a Word crash sooner or later. It is
>> recovering from the crash that is the issue that I am working. Currently
>> I've implemented brute-force killing of all winword.exe process(es)
>> before
>> commencing an extension document from the section in which Word crashed.
>> I
>> was seeking something more elegant.
>>
>> Nigel
>>
>>
>> .
>>
From: Nigel Bufton on
"Nigel Bufton" <nigel(a)bufton.org> wrote in message
news:uz#Bd0ifKHA.2596(a)TK2MSFTNGP04.phx.gbl...
> My application pushes Word to the limit. It can produce documents that
> are hundreds of pages long including many pictures and many shapes (lines,
> rectangles) to create charts. With a large document, Word will "crash"
> (cease to process any more directives) with "memory or disk problem".
>
> Because the documents are created with many sections, the application
> saves the document at the end of each section.
>
> It error traps Word crashing, at which point I need it to quit Word and
> start it afresh - resuming from the start of the section in which it
> crashed.
>
> All of the logic works fine, except in many cases a Quit or Close
> directive fails because Word has reached the end of its tether.
>
> Is there a simple way to close the crashed instance of Word, or do I need
> to use the Windows API to kill the WinWord process. If so, is there any
> easy way of determining which is the process in question if there are more
> than one WinWord process running?
>
> Thanks for any guidance.
>
> Nigel

Thanks for the responses to the above posting. I have one further issue.

In the application, I have:
Set oWord = CreateObject("Word.Application")
oWord.DisplayAlerts = wdAlertsNone
App.OleServerBusyRaiseError = True
App.OleServerBusyTimeout = 10000
App.OleRequestPendingTimeout = 5000

After a few hundred pages, Word displays "The graphics filter was unable to
convert..."

This is an overload situation. As described above, I want to detect this,
kill Word, and restart Word from the start of the current section.

Despite the application code, Word IS displaying an alert and the OLE error
and timeout settings are NOT being executed.

My application is frozen until I manually dismiss the Word dialog display.
Then my application proceeds per design.

Why is Word displaying this message when wdAlertsNone is set?
Why is my app not timing out the OLE request?

What am I missing here?

Thanks,
Nigel