在同一监视器上使用MS Word作为VB.net应用程序中的拼写检查程序

问题描述 投票:0回答:1

我正在使用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帮助)但我无法弄清楚如何让拼写检查窗口在与应用程序相同的监视器上打开?

请帮忙。

先感谢您

vb.net ms-word monitor
1个回答
0
投票

尝试使用

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

而不是MsgBox功能。

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

如果这不起作用,这将:

Centered MessageBox code

© www.soinside.com 2019 - 2024. All rights reserved.