|
- Sub Macro1()
-
- Dim mypath$, wj$, n%, wd, i&, k%
-
- Set wd = CreateObject("Word.Application")
-
- w = Array("合同编号:", "出租方(以下简称甲方):", "联系电话:", "地址:", "承租方(以下简称乙方):", "第一条 场地基本情况", "用途", "第三条 租赁期限")
-
- mypath = ThisWorkbook.Path & ""
-
- wj = Dir(mypath & "*.doc")
-
- Do While wj <> ""
- on error resume next
-
- n = n + 1
-
- With wd.Documents.Open(mypath & wj)
-
- x = Split(.Range, vbCr)
-
- For i = 0 To UBound(x) - 1
-
- For k = 0 To 4
-
- If x(i) Like "*" & w(k) & "*" Then
-
- Cells(n + 1, k + 1) = Split(x(i), w(k))(1)
-
- End If
-
- Next
-
- If x(i) Like "*" & w(5) & "*" Then
-
- Cells(n + 1, 6) = Split(Split(x(i + 1), "位于")(1), ";")(0)
-
- Cells(n + 1, 7) = Split(Split(x(i + 1), "建筑面积")(1), "平方")(0)
-
- End If
-
- If x(i) Like "*" & w(6) & "*" Then
-
- Cells(n + 1, 9) = x(i + 1)
-
- End If
-
- If x(i) Like "*" & w(7) & "*" Then
-
- Cells(n + 1, 10) = Split(Split(x(i + 1), "租赁期限")(1), ",")(0)
-
- Cells(n + 1, 11) = Split(Split(x(i + 1), "自")(1), "至")(0)
-
- Cells(n + 1, 12) = Split(Split(x(i + 1), "至")(1), "止")(0)
-
- End If
-
- Next
-
- .Close False
-
- End With
-
- wj = Dir
-
- Loop
-
- wd.Quit
-
- End Sub
复制代码
老师这是个批量查找指定字符并填写到EXCEL中的代码 是根据段落查找的
但是格式不是很统一 能不能用什么办法修改成全文查找的吗 |
|