- Sub 提取word表格1()
- Dim wApp, myfile, t
- mypath = ThisWorkbook.Path & ""
- myname = Dir(mypath & "*.doc")
- m = 1
- Do While myname <> ""
- Set mydoc = GetObject(mypath & myname)
- With mydoc
- m = m + 1
- mydoc.Content.Find.Execute findtext:=ChrW(163), ReplaceWith:="□", Replace:=2
- With .Tables(1)
- Cells(m, 1) = m - 1
- Cells(m, 2) = "'" & myname
- Range("A1:F1") = Array("序号", "文件名", "报告编号", "住址", "A级", "B级")
- Cells(m, 3) = Replace(.cell(2, 4).Range.Text, "", "")
- Cells(m, 4) = Replace(.cell(5, 2).Range.Text, "", "")
- Cells(m, 5) = Replace(.cell(25, 1).Range.Text, "(", "R")
- Cells(m, 5) = Replace(Cells(m, 5).Text, "", "")
- Cells(m, 5).Characters(Start:=1, Length:=1).Font.Name = "Wingdings 2"
- Cells(m, 5).Characters(Start:=2, Length:=30).Font.Name = "宋体"
- Cells(m, 6) = Replace(.cell(25, 2).Range.Text, "(", "R")
- Cells(m, 6) = Replace(Cells(m, 6).Text, "", "")
- Cells(m, 6).Characters(Start:=1, Length:=1).Font.Name = "Wingdings 2"
- Cells(m, 6).Characters(Start:=2, Length:=30).Font.Name = "宋体"
- End With
- .Close False
- End With
- myname = Dir()
- Loop
- Set mydoc = Nothing
- MsgBox "提取完成"
- End Sub
复制代码 |