【发布时间】:2013-02-25 19:40:00
【问题描述】:
我正在尝试编写一个 VB 脚本,从给定的 MS Word 文档中提取所有以黄色突出显示的文本段落。我的代码似乎 >> 几乎
Sub FindHighlightedText()
'Get current working directory.
Dim pwd As String
pwd = ActiveDocument.Path
Dim Name As String
Name = pwd & "\Output.txt"
' Create a filehandle and open the output file.
handle = FreeFile()
Open Name For Output As #handle
With ActiveDocument.Range.Find
.ClearFormatting
.Highlight = True
.Forward = True
'I THINK THE PROBLEM IS HERE!!
If .Parent.HighlightColorIndex = wdYellow Then
print #handle, .Parent.Text & vbNewLine
End If
End With
' Close the output filehandle.
Close #handle
End Sub
【问题讨论】:
-
这和excel-vba有什么关系?
-
不多,我同意。为错误分类道歉。
标签: vba ms-word text-formatting