Hi honk98,
Hav a look to the VBA code (Word) below which converts Word tables into Excel file.
It's not perfect...but it's the best solution i find.
Create a new Word document.
Tools -> Marcos -> Visual BASIC Editor
Paste the code below
Tools -> Reference -> Select Microsoft Excel 110 object library
Save your new document
To convert a file:
Tools -> Macros -> Macros -> WordToExcel.
The cells of your Word document which could be converted are gray, the
others still white.
Best regards,
MrBzzT
-------------------------------------------------
Option Explicit
Sub WordToExcel()
Dim objExcel As Excel.Application
Dim Wkb As Excel.Workbook
Dim WdCol, WdRow As Integer
Dim XlRow As Integer
Dim idTable As Table
Dim idCell As Cell
Dim idShape As Shape
Dim NbTable As Integer
Dim Ret As Variant
'Open Doc document
With Dialogs(wdDialogFileOpen)
.Name = "*.doc"
Ret = .Show
End With
If Ret <> -1 Then Exit Sub
Application.ScreenUpdating = False
Application.DisplayStatusBar = True
For Each idShape In ActiveDocument.Shapes
If idShape.Type = msoTextBox Then idShape.ConvertToFrame
Next
'Init.
XlRow = 0
NbTable = 0
'Create new Workbook in Excel
Set objExcel = CreateObject("Excel.Application")
Set Wkb = objExcel.Workbooks.Add(xlWBATWorksheet)
Wkb.ActiveSheet.Cells.NumberFormat = "@"
'For each table in current document
For Each idTable In ActiveDocument.Tables
WdRow = 1
WdCol = 1
NbTable = NbTable + 1
Application.StatusBar = "Convert table " & NbTable & "/" &
ActiveDocument.Tables.Count
'Copy each cell in XL Workbook
Do
Wkb.ActiveSheet.Cells(XlRow + WdRow, WdCol).Formula =
CharCleaner(idTable.Cell(WdRow, WdCol).Range.Text)
idTable.Cell(WdRow, WdCol).Shading.BackgroundPatternColor = wdColorGray15
If Not (idTable.Cell(WdRow, WdCol).Next Is Nothing) Then
Set idCell = idTable.Cell(WdRow, WdCol).Next
WdRow = idCell.RowIndex
WdCol = idCell.ColumnIndex
Else
Exit Do
End If
Loop
XlRow = XlRow + WdRow + 1
Next
objExcel.ActiveSheet.Cells.AutoFit
objExcel.Visible = True
Application.ScreenUpdating = True
Application.StatusBar = True
End Sub
Private Function CharCleaner(Text As String)
Dim i As Integer
For i = 1 To Len(Text) - 2
If Asc(Mid(Text, i, 1)) >= 32 Or Mid(Text, i, 1) = vbCr Then
If Mid(Text, i, 1) = vbCr Then
CharCleaner = CharCleaner & vbLf
Else
CharCleaner = CharCleaner & Mid(Text, i, 1)
End If
End If
Next
End Function |