|
楼主 |
发表于 2023-4-18 15:54
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub lqxs_提取数据()
Dim n%, doc, f, wd, arr(1 To 1000, 1 To 4), nm$, m$
On Error Resume Next
f = Dir(ThisWorkbook.Path & "\*.docx")
m = 0
Do While f <> ""
nm = Split(f, "公司")(0) & "公司"
Set wd = GetObject(ThisWorkbook.Path & "\" & f)
With wd
m = m + 1
Set tb = .Tables(1)
With tb
For i = 2 To tb.Rows.Count
n = n + 1
arr(n, 1) = n '编号
arr(n, 2) = nm '公司
arr(n, 3) = qczbf(.cell(i, 2).Range) '资源名称
arr(n, 4) = qczbf(.cell(i, 3).Range) ' 资源描述
Next
End With
wd.Close False
End With
f = Dir()
Loop
Set wd = Nothing
If m <> 0 Then _
Sheet1.Activate
[a3].Resize(5000, 4).ClearContents
[a3].Resize(5000, 4).Borders.LineStyle = xlNone
[a3].Resize(n, 4) = arr
[a3].Resize(n, 4).Borders.LineStyle = 1
MsgBox "完成!"
End Sub
Function qczbf(a)
qczbf = Left(a, Len(a) - 2)
End Function
大神,能按这个帮我修改一下吗,我在论坛找的,自己修改了下,实在不会 |
|