vba怎么判断word中某一部分的字体是否正确
比如说我想测试一下第二段从第三个字到段末的字体是否为我想要的字体,代码该怎么写啊?下面是我写的代码,是有错的,我希望大佬能帮我看看哪里出了错,还有是否可以简化一下,谢啦!
Module Module1
Sub Main()
Dim wordApp As New Microsoft.Office.Interop.Word.Application()
Dim wordDoc As New Microsoft.Office.Interop.Word.Document
Dim score As Long
Dim l As Long
score = 100
l=1
wordDoc = wordApp.Documents.Open("C:\Users\guxp\Desktop\vba\test.docx")
For Each p In wordDoc.Paragraphs
If(l=1)Then
l=0
Continue
End If
If (p.Range(3, -1).Font.Name <> "宋体" Or p.Range(3, -1).Font.Size <> 14) Then
score = 0
End If
Exit For
Next
wordDoc.Close()
wordApp.Quit()
MsgBox(score)
End Sub
End Module