0
我需要使用VBA腳本提取具有特定樣式的所有文本元素。如果該行中存在該樣式,我可以將它打印出來,但我只需要打印與該樣式匹配的文本。用給定樣式提取元素的文本VBA
Dim singleLine As Paragraph
Dim lineText As String
For Each singleLine In ActiveDocument.Paragraphs
lineText = singleLine.Range.Text
'Define the style we're searching for
Dim blnFound As Boolean
With singleLine.Range.Find
.style = "Gloss in Text"
Do
'if we find the style "Gloss in Text" in this line
blnFound = .Execute
If blnFound Then
Debug.Print lineText
Exit Do
End If
Loop
End With
Next singleLine
如何打印標記爲「文本中的光澤」而不是整行的文本的值?