How to Kill the WinWord SpellChecker process I started?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dean Slindee

    How to Kill the WinWord SpellChecker process I started?

    Using this statement to utilize the spell checker in WinWord:
    WinOffice.clsWo rd.SpellChecker (txtNote.Text)

    'this does not work because no main window is displayed
    'Dim proc = Process.GetProc essesByName("wi nword")
    'For i As Integer = 0 To proc.Count - 1
    ' proc(i).CloseMa inWindow()
    'Next i

    'this closes all WinWord processes silently (a little overkill):
    Dim procs() As Process = Process.GetProc essesByName("wi nword")
    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 Slindee

    #2
    Re: How to Kill the WinWord SpellChecker process I started?

    Figured it out. Here is the SpellChecker code. Just commented the last two
    lines, as shown here:
    Public Shared Sub SpellChecker(By Ref strText As String)
    Dim app As Word.Applicatio n = New Word.Applicatio n()
    Dim doc As Word.Document = app.Documents.A dd()

    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.A dd(template, newTemplate, documentType,
    booVisible)
    doc.Words.First .InsertBefore(s trText)
    Dim wpe As Word.Proofreadi ngErrors = doc.SpellingErr ors

    doc.CheckSpelli ng(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(saveCh anges, originalFormat, routeDocument)
    'app = New Word.Applicatio n()
    'doc = app.Documents.A dd()
    End If
    End Sub

    "Dean Slindee" <slindee@charte r.netwrote in message
    news:7283B14A-56FF-484D-9E52-4A03E82D96B0@mi crosoft.com...
    Using this statement to utilize the spell checker in WinWord:
    WinOffice.clsWo rd.SpellChecker (txtNote.Text)
    >
    'this does not work because no main window is displayed
    'Dim proc = Process.GetProc essesByName("wi nword")
    'For i As Integer = 0 To proc.Count - 1
    ' proc(i).CloseMa inWindow()
    'Next i
    >
    'this closes all WinWord processes silently (a little overkill):
    Dim procs() As Process = Process.GetProc essesByName("wi nword")
    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
    >

    Comment

    • kimiraikkonen

      #3
      Re: How to Kill the WinWord SpellChecker process I started?

      On Nov 10, 2:20 am, "Dean Slindee" <slin...@charte r.netwrote:
      Using this statement to utilize the spell checker in WinWord:
               WinOffice.clsWo rd.SpellChecker (txtNote.Text)
      >
               'this does not work because no main window is displayed
               'Dim proc = Process.GetProc essesByName("wi nword")
               'For i As Integer = 0 To proc.Count - 1
               '   proc(i).CloseMa inWindow()
               'Next i
      >
               'this closes all WinWord processes silently (a little overkill):
               Dim procs() As Process = Process.GetProc essesByName("wi nword")
               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

      Comment

      Working...