|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub a()
'必须提前引用word对象
Dim WrdDoc, MyPath, MyFile, i%, m%, t%, ran, s$
Dim app As New Word.Application
i = 2
MyPath = ThisWorkbook.Path
MyFile = Dir(MyPath & "\入库单\*.docx")
Application.ScreenUpdating = False
Do While MyFile <> ""
Set WrdDoc = app.Documents.Open(MyPath & "\入库单\" & MyFile)
app.Visible = True
app.Selection.HomeKey unit:=wdStory
Set ran = WrdDoc.Range
With ran.Find
.ClearFormatting
.Text = "1、"
.Wrap = 1
If .Execute Then
m = ran.Start
i = i + 1
s = WrdDoc.Range(m, WrdDoc.Range.End)
Cells(i, 4) = Left(s, InStr(s, "(以下空白)") - 1)
End If
End With
WrdDoc.Close
MyFile = Dir
Loop
app.Quit
Set app = Nothing
Application.ScreenUpdating = True
End Sub |
评分
-
2
查看全部评分
-
|