0
How can i accesses the controls of this form from my application. my code is working but i am not able to stop it in between checking cell.DataGridViewの選択された列VS2005のVisual Basic .NETの各行スペルチェック
{
プライベートサブButton4_Click(System.EventArgsとしてのSystem.Object、ByValを電子としてByVal送信者)がButton4.Click
を処理Dim emptyItem As Object = System.Reflection.Missing.Value
Dim oNothing As Object = Nothing
Dim oTrue As Object = True
Dim oFalse As Object = False
Dim Loopbreak As Object = False
Dim oAlwaysSuggest As Object = True
Dim oIgnoreUpperCase As Object = False
Dim SpellingErrors As Integer = 0
Dim ErrorCountMessage As String = String.Empty
Dim WordApp As Microsoft.Office.Interop.Word.Application = _
New Microsoft.Office.Interop.Word.Application()
WordApp.Visible = False
Dim ActualValue As String = ""
Dim WordDoc As Word.Document
For rowCnt As Integer = 0 To DataGridView1.Rows.Count - 1
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("winword")
If Loopbreak = False Then
For Each p As Process In pProcess
If p.HasExited Then
p.Kill()
End If
Next
WordDoc = WordApp.Documents.Add
WordDoc.Words.First.InsertBefore(DataGridView1.Rows(rowCnt).Cells(cmbSortColumns.SelectedValue).Value)
Dim docErrors As Microsoft.Office.Interop.Word.ProofreadingErrors = WordDoc.SpellingErrors
SpellingErrors = docErrors.Count
If SpellingErrors > 0 Then
DataGridView1.Rows(rowCnt).Selected = True
WordDoc.CheckSpelling(oNothing, oIgnoreUpperCase, oAlwaysSuggest, oNothing, oNothing, oNothing, oNothing, oNothing, oNothing, oNothing, oNothing, oNothing)
' format a string to contain a report of the errors detected
ErrorCountMessage = "Spell check complete; errors detected: " + SpellingErrors.ToString()
Dim first As Object = 0
Dim last As Object = WordDoc.Characters.Count - 1
ActualValue = DataGridView1.Rows(rowCnt).Cells(cmbSortColumns.SelectedValue).Value
DataGridView1.Rows(rowCnt).Cells(cmbSortColumns.SelectedValue).Value = WordDoc.Range(first, last).Text
If ActualValue = DataGridView1.Rows(rowCnt).Cells(cmbSortColumns.SelectedValue).Value Then
DataGridView1.Rows(rowCnt).Cells(cmbSortColumns.SelectedValue).Style.ForeColor = Color.Red
Loopbreak = True
End If
End If
WordDoc.Activate()
DataGridView1.Rows(rowCnt).Cells(cmbSortColumns.SelectedValue).Style.ForeColor = Color.Red
Else
End If
SpellingErrors = 0
Next
WordApp.Quit(oFalse, emptyItem, emptyItem)
MsgBox("Spell Check Completed")
End Sub
}