1、在工作表中,点击菜单栏【开发工具】,在其工具栏内,点击【visual basic】!

2、会进入VBA编辑界面!点击菜单栏【插入】,在其下拉菜单中,选择【模块】!

3、会弹出模块编辑窗口!

4、在模块窗口输入以下代码:
Sub 提取信息()
Dim wdapp As Object
Set wdapp = CreateObject("word.application")
wdapp.Documents.Open Filename:=ThisWorkbook.Path & "\DEMO\9-5.demo123.docx"
c = wdapp.Documents(1).Range
Set regx = CreateObject("vbscript.regexp")
With regx
.Global = True
.Pattern = "\d+、\S+。"
Set Mat = .Execute(c)
For Each m In Mat
n = n + 1
Cells(n, 1) = m
Next
End With
End Sub

5、点按键盘上的F8,一步步运行编写的代码!同时可以检查代码是否正确!

6、运行完毕后,所需的结果被提取到EXCEL表中。
