【发布时间】:2020-05-12 07:14:04
【问题描述】:
我有包含某些序列号的 Word 文档(它们都以 3BMS* 或 7SGA* 开头),我需要将其提取到 Excel 中。每个 Word 文档都包含数百个序列号。
我正在尝试的方法是 VBA 打开 Word 文档并使用搜索来查找包含序列号前四位数字的单词。然后,我将为这两个代码中的每一个运行代码。
我有 VBA 来查找包含搜索词的段落。
While oRange.Find.Execute = True
oRange.Select
myPara = oDoc.Range(0, oWord.Selection.Paragraphs(1).Range.End).Paragraphs.Count
CurrRowShtExtract = CurrRowShtExtract + 1
shtExtract.Cells(CurrRowShtExtract, 1) = oDoc.Paragraphs(myPara).Range
oRange.Collapse wdCollapseEnd
Wend
如何只返回包含搜索结果的单词,而不是整个段落?
【问题讨论】:
-
也许使用
Regexp?例如this