VBA复制从单词表到Excel

我试图从一个word文件(从word表复制到excel)的特定表格单元格中生成5列的excel文件。 我的文件有280个表格。 我在解决我想从我的文件中复制的单元格时没有问题。 但我不知道为什么结果是一个空白的Excel文件。 也许我错在粘贴方法呃我不知道…。 这是我的代码:

Sub copyfromwordtoexcel() Dim exApp As Excel.Application Dim exDoc As Excel.Workbook Set exApp = CreateObject("Excel.Application") Set exDoc = exApp.Workbooks.Add For xx = 1 To ActiveDocument.Tables.Count On Error Resume Next ActiveDocument.Tables(xx).Cell(2, 2).Range.Copy exApp.Visible = True Cells(xx, 1).Select ActiveSheet.Paste Application.Visible = True exApp.Visible = False ActiveDocument.Tables(xx).Cell(3, 2).Range.Copy exApp.Visible = True Cells(xx, 2).Select ActiveSheet.Paste i = ActiveDocument.Tables(xx).Rows.Count ActiveDocument.Tables(xx).Cell(i - 2, 2).Range.Copy exApp.Visible = True Cells(xx, 3).Select ActiveSheet.Paste Application.Visible = True ActiveDocument.Tables(xx).Cell(i - 1, 2).Range.Copy exApp.Visible = True Cells(xx, 4).Select ActiveSheet.Paste Application.Visible = True ActiveDocument.Tables(xx).Cell(i, 2).Range.Copy exApp.Visible = True Cells(xx, 5).Select ActiveSheet.Paste Application.Visible = True exApp.Visible = True Next End Sub 

谢谢你的帮助

经过一番审查,我发现我应该使用pastespecial在我的粘贴纠正的代码是波纹pipe

 Sub copyfromwordtoexcel() Dim exApp As Excel.Application Dim exDoc As Excel.Workbook Set exApp = CreateObject("Excel.Application") Set exDoc = exApp.Workbooks.Add For xx = 1 To ActiveDocument.Tables.Count On Error Resume Next If ActiveDocument.Tables(xx).Columns.Count = 2 Then ActiveDocument.Tables(xx).Cell(2, 2).Range.Copy exApp.Visible = True Cells(xx, 1).Select ActiveSheet.PasteSpecial (xlPasteAll) Application.Visible = True exApp.Visible = False ActiveDocument.Tables(xx).Cell(3, 2).Range.Copy exApp.Visible = True Cells(xx, 2).Select ActiveSheet.PasteSpecial (xlPasteAll) i = ActiveDocument.Tables(xx).Rows.Count ActiveDocument.Tables(xx).Cell(i - 2, 2).Range.Copy exApp.Visible = True Cells(xx, 3).Select ActiveSheet.PasteSpecial (xlPasteAll) Application.Visible = True ActiveDocument.Tables(xx).Cell(i - 1, 2).Range.Copy exApp.Visible = True Cells(xx, 4).Select ActiveSheet.PasteSpecial (xlPasteAll) Application.Visible = True ActiveDocument.Tables(xx).Cell(i, 2).Range.Copy exApp.Visible = True Cells(xx, 5).Select ActiveSheet.PasteSpecial (xlPasteAll) Application.Visible = True exApp.Visible = True End If Next 

结束小组