在同一台显示器的VB.net应用程序中将MS Word用作拼写检查器

时间:2019-04-23 13:43:27

标签: vb.net ms-word monitor

我正在使用http://www.vb-helper.com/howto_net_spellcheck.html中的代码,该代码使用Microsoft Word的拼写检查器,并进行了略微修改以适合我的应用程序。但是有时,拼写检查窗口会在辅助监视器上打开,并且需要在与VB.net应用程序相同的监视器上打开它。在用户测试期间,用户无法找到拼写检查窗口,因为该窗口位于其另一台监视器上。

我知道一些VB.net,但显然不足以解决此问题。我已经在特定的显示器上搜索过Google,并且大多是在打开VB表单,但这不是我想要的。我的代码:

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

哪个可以正常工作(谢谢VB Helper),但是我不知道如何在与应用程序相同的监视器上打开拼写检查窗口?

请帮助。

提前谢谢

1 个答案:

答案 0 :(得分:0)

尝试使用

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

代替MsgBox函数。

使用Me,您可以指定MessageBox的所有者为您的应用程序形式。

如果这不起作用,它将:

Centered MessageBox code