I\'m trying to generate an excel file with 5 column from specific tables\' cells in a word file (copy from word table to excel). My word file has 280 tables. I have no probl
After some review, i;ve found that i shoud use pastespecial in my paste the corrected code is bellow
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
End Sub