我正在尝试使用 vba word 更改段落中的文本。以下代码导致 Next 不转到集合中的下一个元素。
Sub ReadPara()
Dim myString$
Dim DocPara As Paragraph
For Each DocPara In ActiveDocument.Paragraphs
'Debug.Print DocPara.Range.ParagraphStyle '; " - "; DocPara.Range.Text
If Left(DocPara.Range.ParagraphStyle, Len("Heading")) = "Heading" Then
Debug.Print DocPara.Range.ListFormat.ListString
End If
'This section does not go to the next element in the collection
If InStr(DocPara.Range.Text, "HW") > 1 Then
Debug.Print DocPar; qa.Range.Text
myString$ = DocPara.Range.Text
DocPara.Range.Text = myString$ & "Changed"
' Debug.Print DocPara.Range.Text
End If
Next DocPara
End Sub