|
楼主 |
发表于 2020-12-16 21:15
|
显示全部楼层
只复制WORD中其中一张表格内容
- Sub 提取WORD中木一个表格到EXCELL中()
- '更多下载www.15161218108.ys168.com
- Dim tim2 As Date: tim1 = Timer
- Dim JJ As Integer
- JJ = Application.InputBox("请输入想复制的工作是WORD中的第几个表!", "提示", , , , , , 1)
- Cells.ClearContents
-
- Dim NEWD As Object, wddct As Object
- Dim F, arr, brr, i&, j&
- F = Application.GetOpenFilename(fileFilter:="Word文件(*.doc*),*.doc*", Title:="选择Word文件", MultiSelect:=True)
- If TypeName(F) = "Boolean" Then
- Exit Sub
- Else
- FPATH = Replace(F(1), Dir(F(1)), "")
- End If
- F = Dir(FPATH & "*.doc*")
- Set NEWD = CreateObject("Word.Application")
- i = 2
- Do Until F = "" '只要文件名存在
- F = FPATH & F
- Set WD = NEWD.Documents.Open(filename:=F)
- With WD
- WDN = Split(WD, ".")(0)
- On Error Resume Next
- '提取每个表格内容
- 'x = Application.InputBox("请输入想复制的工作是WORD中的第几个表!", "提示", , , , , , 1)
- On Error Resume Next
- With .Tables(JJ)
- N = N + 1
- If N = 1 Then
- Range("B1").Activate
- .Range.Copy
- Sheet1.Paste
- Else
- r = Sheet1.UsedRange.SpecialCells(11).Row + 1
- Range("B" & r).Activate
- .Range.Copy
- Sheet1.Paste
- End If
- With Selection
- BT = .Columns(1).Offset(, -1 * (.Column - 1)).Address
- Range(BT) = WDN
- End With
- End With
- End With
- Set WD = Nothing
- F = Dir
- i = i + 1
- Loop
- NEWD.Quit
- Set NEWD = Nothing
- Application.ScreenUpdating = True
- tim2 = Timer
- MsgBox Format(tim2 - tim1, "提取完成,共耗时:0.00秒"), 64, "时间统计"
- End Sub
复制代码
|
|