ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
楼主: lsc900707

[交流] 我的2016年vba学习总结

[复制链接]

TA的精华主题

TA的得分主题

 楼主| 发表于 2017-1-6 20:58 | 显示全部楼层
我的另一个帖子,是关于word转excel的,之前看过多个单独的几份简历汇总到excel的,但没有看过一个word中多份简历汇总的,所以求助.
如何提取word文档中多个简历信息至excel汇总表
http://club.excelhome.net/thread-1291824-1-1.html
(出处: ExcelHome技术论坛)
感谢hhjjpp大侠及时施以援手,使得问题得以解决:

Private Sub CommandButton1_Click()
Dim wd, i&
Set wd = CreateObject("word.application")
wd.Documents.Open ThisWorkbook.Path & "\简历信息表.doc"
With wd.activedocument
   For i = 1 To .Tables.Count
       Cells(i + 1, "b") = Replace(.Tables(i).Cell(2, 2), Chr(7), "")
       Cells(i + 1, "c") = Replace(.Tables(i).Cell(2, 4), Chr(7), "")
       Cells(i + 1, "d") = Replace(.Tables(i).Cell(2, 6), Chr(7), "")
       Cells(i + 1, "e") = Replace(.Tables(i).Cell(3, 2), Chr(7), "")
       Cells(i + 1, "f") = Replace(.Tables(i).Cell(3, 4), Chr(7), "")
       Cells(i + 1, "g") = Replace(.Tables(i).Cell(3, 6), Chr(7), "")
       Cells(i + 1, "h") = Replace(.Tables(i).Cell(4, 2), Chr(7), "")
       Cells(i + 1, "i") = Replace(.Tables(i).Cell(4, 4), Chr(7), "")
       Cells(i + 1, "j") = Replace(.Tables(i).Cell(5, 2), Chr(7), "")
       Cells(i + 1, "k") = Replace(.Tables(i).Cell(5, 4), Chr(7), "")
       Cells(i + 1, "l") = Replace(.Tables(i).Cell(6, 3), Chr(7), "")
       Cells(i + 1, "m") = Replace(.Tables(i).Cell(6, 5), Chr(7), "")
       Cells(i + 1, "n") = Replace(.Tables(i).Cell(7, 3), Chr(7), "")
       Cells(i + 1, "o") = Replace(.Tables(i).Cell(7, 5), Chr(7), "")
       Cells(i + 1, "p") = Replace(.Tables(i).Cell(8, 2), Chr(7), "")
       Cells(i + 1, "q") = Replace(.Tables(i).Cell(8, 4), Chr(7), "")
       Cells(i + 1, "r") = Replace(.Tables(i).Cell(9, 2), Chr(7), "")
       Cells(i + 1, "s") = Replace(.Tables(i).Cell(9, 4), Chr(7), "")
       Cells(i + 1, "t") = Replace(.Tables(i).Cell(9, 6), Chr(7), "")
       Cells(i + 1, "u") = Replace(.Tables(i).Cell(10, 2), Chr(7), "")
       Cells(i + 1, "v") = Replace(.Tables(i).Cell(13, 2), Chr(7), "")
       Cells(i + 1, "w") = Replace(.Tables(i).Cell(13, 3), Chr(7), "")
       Cells(i + 1, "x") = Replace(.Tables(i).Cell(14, 2), Chr(7), "")
       Cells(i + 1, "y") = Replace(.Tables(i).Cell(14, 3), Chr(7), "")
       Cells(i + 1, "z") = Replace(.Tables(i).Cell(14, 4), Chr(7), "")
       Cells(i + 1, "aa") = Replace(.Tables(i).Cell(15, 2), Chr(7), "")
       Cells(i + 1, "ab") = Replace(.Tables(i).Cell(15, 3), Chr(7), "")
       Cells(i + 1, "ac") = Replace(.Tables(i).Cell(15, 4), Chr(7), "")
       Cells(i + 1, "ad") = Replace(.Tables(i).Cell(16, 2), Chr(7), "")
       Cells(i + 1, "ae") = Replace(.Tables(i).Cell(16, 3), Chr(7), "")
       Cells(i + 1, "af") = Replace(.Tables(i).Cell(16, 4), Chr(7), "")
       Cells(i + 1, "ag") = Replace(.Tables(i).Cell(19, 1), Chr(7), " ") & Replace(.Tables(i).Cell(19, 2), Chr(7), " ") & Replace(.Tables(i).Cell(19, 3), Chr(7), " ") & Replace(.Tables(i).Cell(19, 4), Chr(7), Chr(13)) & Replace(.Tables(i).Cell(20, 1), Chr(7), " ") & Replace(.Tables(i).Cell(20, 2), Chr(7), " ") & Replace(.Tables(i).Cell(20, 3), Chr(7), " ") & Replace(.Tables(i).Cell(20, 4), Chr(7), "")
       Cells(i + 1, "ah") = Replace(.Tables(i).Cell(23, 1), Chr(7), " ") & Replace(.Tables(i).Cell(23, 2), Chr(7), " ") & Replace(.Tables(i).Cell(23, 3), Chr(7), " ") & Replace(.Tables(i).Cell(23, 4), Chr(7), Chr(13)) & Replace(.Tables(i).Cell(24, 1), Chr(7), " ") & Replace(.Tables(i).Cell(24, 2), Chr(7), " ") & Replace(.Tables(i).Cell(24, 3), Chr(7), " ") & Replace(.Tables(i).Cell(24, 4), Chr(7), "")
       Cells(i + 1, "ai") = Replace(.Tables(i).Cell(29, 1), Chr(7), "")
    Next
.Close False
wd.Quit
End With

End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2017-1-6 21:03 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
以下代码感谢http://club.excelhome.net/home.php?mod=space&uid=3195546大侠提供思路和框架:

Sub word文档转excel汇总()
     On Error Resume Next
     [A2:AI250].ClearContents
     Application.ScreenUpdating = False
     Dim cPath$, cFile$, str$, i%, arr(1 To 500, 1 To 35)
     Dim wordD As Word.Document
     Dim Wordapp As Object
     Set Wordapp = CreateObject("Word.Application")
     cPath = ThisWorkbook.Path & "\"
     cFile = Dir(cPath & "*.doc?")
     Do While cFile <> ""
         Set wordD = Wordapp.Documents.Open(cPath & cFile)
         For i = 1 To wordD.Tables.Count
             With wordD.Tables(i)
                 arr(i, 1) = i
                 arr(i, 2) = Replace(.Cell(2, 2).Range.Text, Chr(7), "")
                 arr(i, 3) = Replace(.Cell(2, 4).Range.Text, Chr(7), "")
                 arr(i, 4) = Replace(.Cell(2, 6).Range.Text, Chr(7), "")
                 arr(i, 5) = Replace(.Cell(3, 2).Range.Text, Chr(7), "")
                 arr(i, 6) = Replace(.Cell(3, 4).Range.Text, Chr(7), "")
                 arr(i, 7) = Replace(.Cell(3, 6).Range.Text, Chr(7), "")
                 arr(i, 8) = Replace(.Cell(4, 2).Range.Text, Chr(7), "")
                 arr(i, 9) = Replace(.Cell(4, 4).Range.Text, Chr(7), "")
                 arr(i, 10) = Replace(.Cell(5, 2).Range.Text, Chr(7), "")
                 arr(i, 11) = Replace(.Cell(5, 4).Range.Text, Chr(7), "")
                 arr(i, 12) = Replace(.Cell(6, 3).Range.Text, Chr(7), "")
                 arr(i, 13) = Replace(.Cell(6, 5).Range.Text, Chr(7), "")
                 arr(i, 14) = Replace(.Cell(7, 3).Range.Text, Chr(7), "")
                 arr(i, 15) = Replace(.Cell(7, 5).Range.Text, Chr(7), "")
                 arr(i, 16) = Replace(.Cell(8, 2).Range.Text, Chr(7), "")
                 arr(i, 17) = Replace(.Cell(8, 4).Range.Text, Chr(7), "")
                 arr(i, 18) = Replace(.Cell(9, 2).Range.Text, Chr(7), "")
                 arr(i, 19) = Replace(.Cell(9, 4).Range.Text, Chr(7), "")
                 arr(i, 20) = Replace(.Cell(9, 6).Range.Text, Chr(7), "")
                 arr(i, 21) = Replace(.Cell(10, 2).Range.Text, Chr(7), "")
                 arr(i, 22) = Replace(.Cell(13, 2).Range.Text, Chr(7), "")
                 arr(i, 23) = Replace(.Cell(13, 3).Range.Text, Chr(7), "")
                 arr(i, 24) = Replace(.Cell(14, 2).Range.Text, Chr(7), "")
                 arr(i, 25) = Replace(.Cell(14, 3).Range.Text, Chr(7), "")
                 arr(i, 26) = Replace(.Cell(14, 4).Range.Text, Chr(7), "")
                 arr(i, 27) = Replace(.Cell(15, 2).Range.Text, Chr(7), "")
                 arr(i, 28) = Replace(.Cell(15, 3).Range.Text, Chr(7), "")
                 arr(i, 29) = Replace(.Cell(15, 4).Range.Text, Chr(7), "")
                 arr(i, 30) = Replace(.Cell(16, 2).Range.Text, Chr(7), "")
                 arr(i, 31) = Replace(.Cell(16, 3).Range.Text, Chr(7), "")
                 arr(i, 32) = Replace(.Cell(16, 4).Range.Text, Chr(7), "")
                 arr(i, 33) = Replace(.Cell(19, 1).Range.Text, Chr(7), "") & Replace(.Cell(19, 2).Range.Text, Chr(7), "") _
                   & Replace(.Cell(19, 3).Range.Text, Chr(7), "") & Replace(.Cell(19, 4).Range.Text, Chr(7), "") & Chr(13) _
                   & Replace(.Cell(20, 1).Range.Text, Chr(7), "") & Replace(.Cell(20, 2).Range.Text, Chr(7), "") _
                   & Replace(.Cell(20, 3).Range.Text, Chr(7), "") & Replace(.Cell(20, 4).Range.Text, Chr(7), "")
                 arr(i, 34) = Replace(.Cell(23, 1).Range.Text, Chr(7), "") & Replace(.Cell(23, 2).Range.Text, Chr(7), "") _
                   & Replace(.Cell(23, 3).Range.Text, Chr(7), "") & Replace(.Cell(23, 4).Range.Text, Chr(7), "") _
                   & Replace(.Cell(23, 5).Range.Text, Chr(7), "") & Replace(.Cell(23, 6).Range.Text, Chr(7), "") & Chr(13) _
                   & Replace(.Cell(24, 1).Range.Text, Chr(7), "") & Replace(.Cell(24, 2).Range.Text, Chr(7), "") _
                   & Replace(.Cell(24, 3).Range.Text, Chr(7), "") & Replace(.Cell(24, 4).Range.Text, Chr(7), "") _
                   & Replace(.Cell(24, 5).Range.Text, Chr(7), "") & Replace(.Cell(24, 6).Range.Text, Chr(7), "")
                 arr(i, 35) = Replace(.Cell(29, 1).Range.Text, Chr(7), "")
           
         End With
         Next
         wordD.Close
         cFile = Dir
     Loop
     Set wordD = Nothing
     Wordapp.Quit
     Sheet1.Range("A2").Resize(i, 35) = arr
     Application.ScreenUpdating = True
End Sub

TA的精华主题

TA的得分主题

发表于 2017-1-15 20:41 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2017-1-15 21:02 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
l沙漠中的绿洲f 发表于 2017-1-15 20:41
太棒了。你学习的动力是什么呀?

一是兴趣,二是怕无所事事,浑浑噩噩过日子。

TA的精华主题

TA的得分主题

发表于 2017-1-15 21:06 | 显示全部楼层
lsc900707 发表于 2017-1-15 21:02
一是兴趣,二是怕无所事事,浑浑噩噩过日子。

是我学习的榜样!赞一个

TA的精华主题

TA的得分主题

 楼主| 发表于 2017-1-15 21:08 | 显示全部楼层
l沙漠中的绿洲f 发表于 2017-1-15 21:06
是我学习的榜样!赞一个

用点心,大家都可以的,你们的条件应该比我更优越。

TA的精华主题

TA的得分主题

发表于 2017-1-28 07:27 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2017-1-28 07:51 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2017-1-31 21:03 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2017-1-31 21:14 | 显示全部楼层
lsc900707 发表于 2017-1-1 14:56
这两个帖子很快得到大师们的答复,我很感动。觉得EH就像个家,很温馨。大师们乐于助人的精神令我钦佩。在这 ...

你也从昨天的小白,变成了今天的大师
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-25 23:41 , Processed in 0.037211 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表