VBA将多个WORD中表格批量汇总到同一excel文件中

如题所述

第1个回答  2019-10-06
WORD中的简历有规律的话,或者有标记的话,是比较容易解决的。
示例:
Sub
test()
Dim
mFolder
As
String
Dim
i
As
Integer
mFolder
=
"f:\111"
'修改这个地方就是存放文件的地方
[A1]
=
"路径":
[B1]
=
"文件名"
With
Application.FileSearch
.NewSearch
.LookIn
=
mFolder
.SearchSubFolders
=
True
.Filename
=
"*.*"
If
.Execute()
>
0
Then
For
i
=
1
To
.FoundFiles.Count
If
.FoundFiles(i)
<>
ThisWorkbook.FullName
Then
Call
Write_In(.FoundFiles(i))
End
If
Next
i
Else
MsgBox
"文件夹
"
&
mFolder
&
"中没有所需的文件"
End
If
End
With
End
Sub
Sub
Write_In(strFile
As
String)
Dim
intStart
As
Integer,
intEnd
As
Integer,
iRow
As
Long
Dim
strFileName
As
String
intStart
=
InStrRev(strFile,
"\")
intEnd
=
InStrRev(strFile,
".")
strFileName
=
Mid(strFile,
intStart
+
1,
intEnd
-
intStart
-
1)
Application.ScreenUpdating
=
False
With
Sheet1
iRow
=
.[a65536].End(xlUp).Row
+
1
.Cells(iRow,
1)
=
strFile
.Cells(iRow,
2)
=
strFileName
End
With
Application.ScreenUpdating
=
True
End
Sub
相似回答
大家正在搜