有一份文件说如下:
我想将其转换为:
我想知道我如何迭代编号列表集合来实现这个宏。
答案 0 :(得分:0)
你可以像这样迭代:
Sub iterateNumberedList()
Dim oList As Paragraph
Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst ' go to beginning of doc
' for each paragraph
For Each oList In ActiveDocument.Paragraphs
' is it a numbered list of level 1 ?
If oList.Range.ListFormat.ListType = 4 And oList.Range.ListFormat.ListLevelNumber = 1 Then
' move one line above list item
Selection.MoveUp unit:=wdLine, Count:=1
' insert heading text
Selection.Range.Text = "Heading " & vbCr
' format heading text with style 'Heading 1'
Selection.Range.Style = "Heading 1"
' move down two paragraphs
Selection.MoveDown unit:=wdParagraph, Count:=2
End If
Next
End Sub
此代码只是为了让您了解该怎么做。它并不意味着是您问题的最终解决方案。