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

多个相同的简历,汇总到同一个excel表格里。
2024-12-21 11:00:11
推荐回答(5个)
回答1:

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:

以下是您需要的回答
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

回答3:

在一个新建excel表格中一个单元格输入:“=”
切换到另一个excel表格
将新建的EXCEL表格先保存、关闭。然后重新打开即可。

回答4:

word中的表格是一个table对象,vba代码中可遍历word文件夹中各文件,依次打开,将其中的table对象即表格复制到excel中,楼上的神马不敢苟同

回答5:

去看教材吧