如何通过VB.NET删除Microsoft Word文档中的彩色文本?

时间:2017-08-30 19:28:49

标签: vb.net vba ms-word

如何通过

删除 Microsoft Word 中的彩色文字
Public Class Form1
    Dim oWord As Word.Application 
    Dim oDoc As Word.Document 
    Dim oRng As Word.Range 

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    oWord = New Word.Application 
    oDoc = oWord.Documents.Open("C:\file.docx") 
    oWord.Visible = True 
    oRng = oDoc.Content 
    If oRng.Font.Color = Word.WdColor.wdColorBlack Then 
        oRng.Delete() 
    End If 
    oWord.Documents.Item(1).Save() 
    oWord.Quit() 
    oWord = Nothing 
    End Sub 
End Class

0 个答案:

没有答案