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

多个相同的简历,汇总到同一个excel表格里。

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追问

谢谢,试着跑了一下
结果只是把各个word文件的文件名导入到excel表格里了。
怎么能实现每个word文件里的表格都导入进来呢?
谢谢

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-07-19
以下是您需要的回答
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
第2个回答  2011-07-19
在一个新建excel表格中一个单元格输入:“=”
切换到另一个excel表格
将新建的EXCEL表格先保存、关闭。然后重新打开即可。
第3个回答  2011-07-20
word中的表格是一个table对象,vba代码中可遍历word文件夹中各文件,依次打开,将其中的table对象即表格复制到excel中,楼上的神马不敢苟同
第4个回答  2011-07-21
去看教材吧
相似回答