简体   繁体   English

使用 Excel VBA 在 Word 中删除项目符号段落

[英]Deleting Bullet Paragraph in Word using Excel VBA

I have the following text within a word document:我在word文档中有以下文本:

Total Amount Owed: <<Payment>>
Dates Mowed:
•   2/6/2019
•   2/14/2019
•   <<Mowing1>>

How do I complelely remove the text and bullet point for the line containing the string <<Mowing1>> using VBA?如何使用 VBA 完全删除包含字符串<<Mowing1>>的行的文本和项目符号点?

Thank you in advance!先感谢您!

May try可以试试

Sub test()
Dim Pg As Paragraph,PgTxt as String

    For Each Pg In ActiveDocument.Paragraphs
        If Not Pg.Range.ListFormat.List Is Nothing Then  'Process only bulleted list
        PgTxt = Pg.Range.Text
            If InStr(1, PgTxt, "<<Mowing1>>") > 0 Then
            Pg.Range.Delete
            End If
        End If
    Next
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM