使用VBA提取word文档中的表格数据 新建一个excel文档,在VBA编辑界面操作 添加用户界面:
UserForml
[■ p ■ ■ ■ 日 B
「文件挪径:
开始
代码:
Private Sub Comma ndButto n1_Click()
Dim s As Stri ng
s = TextBox2.Text
Dim fs, myfolder, myfile, myfiles, wdapp, mydoc
Dim mTable As Table, mCell As Cell
Set fs = CreateObject(Scriptin g.FileSystemObject)
Set myfolder = fs.GetFolder(s)
Set myfiles = myfolder.Files
Dim m, n As In teger
m = 0
n = 1
For Each myfile In myfiles
m = m + 1
Set wdapp = CreateObject(word.applicati on)
wdapp.Docume nts.Ope n myfile .P ath
wdapp.Visible = False
wdapp.Visible = True
Set mydoc = wdapp.Docume nts.l tem(m
原创力文档

文档评论(0)