Checking Font Styles In Word Document Using VB.NET

回眸只為那壹抹淺笑 提交于 2019-12-06 03:32:26

With the foolowing code you can find sentences where font style is different.

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Dim oDoc As New Word.Document()
    Dim wapp As New Word.Application()

    Try
        oDoc = wapp.Documents.Open(TextBox1.Text & "\" & "TEST.doc")

        For Each Senetence As Word.Range In oDoc.Sentences
            For Each Character As Word.Range In Senetence.Characters
                If Character.Font.Name <> "Verdana" AndAlso Character.Font.Name <> "Arial" Then
                    MsgBox(" Font Name not matching Error Line number " & Senetence.Text)
                    Exit For
                End If
            Next
        Next
        oDoc.Close()
    Catch ex As Exception
        oDoc.Close()
    End Try

End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!