0

I am using the code from http://www.vb-helper.com/howto_net_spellcheck.html that uses Microsoft Word's spell checker and modified slightly to fit my application. But sometimes the spell check window opens on the secondary monitor and need it to open on the same monitor as the VB.net application. During user testing, user's are unable to locate the spell check window because it's on their other monitor.

I know a little VB.net but obviously not enough to solve this problem. I have Googled and mostly open VB form on a particular monitor but that isn't what I'm after. My code:

If RTBProposedProcedure.Text.Length > 0 Then
        'Make a Word server object.
        Dim word_server As New Word.Application With {.Visible = False}  'Hide the server.              
        Dim doc As Word.Document = word_server.Documents.Add()  ' Make a Word Document.
        Dim rng As Word.Range
        rng = doc.Range() 'Make a Range to represent the Document.
        rng.Text = RTBProposedProcedure.Text  ' Copy the text into the Document.
        doc.Activate() ' Activate the Document and call its CheckSpelling method.
        doc.CheckSpelling()
        Dim chars() As Char = {CType(vbCr, Char), CType(vbLf, Char)} 'Copy the results back into the TextBox, trimming off trailing CR and LF chars.
        RTBProposedProcedure.Text = doc.Range().Text.Trim(chars)
        doc.Close(SaveChanges:=False)  ' Close the Document, not saving changes.
        word_server.Quit()   ' Close the Word server.
        MsgBox("Spelling Check Finished", MsgBoxStyle.Information)
    End If

Which works fine (thank you VB Helper) but I can't figure out how to get the spell check window to open on the same monitor as the application?

Please help.

Thank you in advance

  • Possible duplicate of [Show a MessageBox centered in form](https://stackoverflow.com/questions/15904610/show-a-messagebox-centered-in-form) – Albert Apr 26 '19 at 12:32

1 Answers1

0

Try using

MessageBox.Show(Me, "Spelling Check Finished", "Finished", MessageBoxButtons.OK, MessageBoxIcon.Information)

instead of the MsgBox function.

With the Me you specify that the owner of the MessageBox is the form of your application.

If this does not work, this will:

Centered MessageBox code

Albert
  • 487
  • 1
  • 4
  • 16