By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,532 Members | 1,514 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,532 IT Pros & Developers. It's quick & easy.

How to Kill the WinWord SpellChecker process I started?

P: n/a
Using this statement to utilize the spell checker in WinWord:
WinOffice.clsWord.SpellChecker(txtNote.Text)

'this does not work because no main window is displayed
'Dim proc = Process.GetProcessesByName("winword")
'For i As Integer = 0 To proc.Count - 1
' proc(i).CloseMainWindow()
'Next i

'this closes all WinWord processes silently (a little overkill):
Dim procs() As Process = Process.GetProcessesByName("winword")
For i As Integer = 0 To procs.Count - 1
procs(i).Kill()
Next i

Is there a way to kill only the WinWord process I started by calling
SpellChecker?

Thanks,
Dean S

Nov 10 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Figured it out. Here is the SpellChecker code. Just commented the last two
lines, as shown here:
Public Shared Sub SpellChecker(ByRef strText As String)
Dim app As Word.Application = New Word.Application()
Dim doc As Word.Document = app.Documents.Add()

If (strText.Length 0) Then
app.Visible = False
app.WindowState = 0

Dim template As Object = Missing.Value
Dim newTemplate As Object = Missing.Value
Dim documentType As Object = Missing.Value
Dim booVisible As Object = False
Dim optionalParm As Object = Missing.Value

doc = app.Documents.Add(template, newTemplate, documentType,
booVisible)
doc.Words.First.InsertBefore(strText)
Dim wpe As Word.ProofreadingErrors = doc.SpellingErrors

doc.CheckSpelling(optionalParm, optionalParm, optionalParm,
optionalParm, optionalParm, optionalParm, optionalParm, optionalParm,
optionalParm, optionalParm, optionalParm, optionalParm)
strText = doc.Range(0, doc.Characters.Count - 1).Text

Dim saveChanges As Object = False
Dim originalFormat As Object = Missing.Value
Dim routeDocument As Object = Missing.Value
app.Quit(saveChanges, originalFormat, routeDocument)
'app = New Word.Application()
'doc = app.Documents.Add()
End If
End Sub

"Dean Slindee" <sl*****@charter.netwrote in message
news:72**********************************@microsof t.com...
Using this statement to utilize the spell checker in WinWord:
WinOffice.clsWord.SpellChecker(txtNote.Text)

'this does not work because no main window is displayed
'Dim proc = Process.GetProcessesByName("winword")
'For i As Integer = 0 To proc.Count - 1
' proc(i).CloseMainWindow()
'Next i

'this closes all WinWord processes silently (a little overkill):
Dim procs() As Process = Process.GetProcessesByName("winword")
For i As Integer = 0 To procs.Count - 1
procs(i).Kill()
Next i

Is there a way to kill only the WinWord process I started by calling
SpellChecker?

Thanks,
Dean S
Nov 10 '08 #2

P: n/a
On Nov 10, 2:20*am, "Dean Slindee" <slin...@charter.netwrote:
Using this statement to utilize the spell checker in WinWord:
* * * * *WinOffice.clsWord.SpellChecker(txtNote.Text)

* * * * *'this does not work because no main window is displayed
* * * * *'Dim proc = Process.GetProcessesByName("winword")
* * * * *'For i As Integer = 0 To proc.Count - 1
* * * * *' * proc(i).CloseMainWindow()
* * * * *'Next i

* * * * *'this closes all WinWord processes silently (a little overkill):
* * * * *Dim procs() As Process = Process.GetProcessesByName("winword")
* * * * *For i As Integer = 0 To procs.Count - 1
* * * * * * procs(i).Kill()
* * * * *Next i

Is there a way to kill only the WinWord process I started by calling
SpellChecker?

Thanks,
Dean S
Dean,
As my opinion, killing Word directly using Kill method may cause
unexpected behaviours in next executions of Word such as warnings of
recovered documents etc, so use "Quit" method instead.

Onur Güzel
Nov 10 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.