Nina,
....had beginner's luck. Try this code. It's for exporting
all tables from a word doc to excel, one after another. In
case anyone refines this, drop me a note please.
Sub export()
'excel variables
Dim aex As Excel.Application
Dim wbex As Excel.Workbook
Dim shex As Excel.Worksheet
Dim raex As Excel.Range
Set aex = New Excel.Application
Set wbex = aex.Workbooks.Add
Set shex = wbex.Worksheets.Add
wbex.Worksheets("Sheet1").Delete
wbex.Worksheets("Sheet2").Delete
wbex.Worksheets("Sheet3").Delete
shex.Unprotect
'word variables
Dim t As Word.Table
'word properties
Dim nRows As Integer
Dim ncols As Integer
Dim cRow As Integer, cCol As Integer
Dim scont As String
shex.Name = "Extracted"
For Each t In ActiveDocument.Tables
nRows = t.Rows.Count
ncols = t.Columns.Count
Dim neRows As Integer, neCols As Integer 'excel
Set shex = wbex.Worksheets(1)
DetermineUsedRange wbex.Worksheets("Extracted"), raex
If raex Is Nothing Then
neRows = 0
neCols = 0
Else
neRows = raex.Rows.Count + 1
neCols = raex.Columns.Count
End If
For cRow = 1 To nRows
For cCol = 1 To ncols
scont = Trim(CStr(t.Cell(cRow,
cCol).Range.Text))
shex.Cells(neRows + cRow, cCol) = Left
(scont, Len(scont) - 2)
'shex.Cells(cRow, cCol).Formula = Left
(scont, Len(scont) - 2)
Next cCol
Next cRow
Next t
wbex.SaveAs "c:\temp\newfile.xls"
wbex.Close
End Sub
Sub DetermineUsedRange(ByRef xs As Excel.Worksheet, ByRef
theRng As Excel.Range)
Dim nFirstRow As Integer, nFirstCol As Integer, _
nlastrow As Integer, nlastcol As Integer
On Error GoTo handleError
nFirstRow = xs.Cells.Find(What:="*", _
SearchDirection:=xlNext, _
SearchOrder:=xlByRows).Row
nFirstCol = xs.Cells.Find(What:="*", _
SearchDirection:=xlNext, _
SearchOrder:=xlByColumns).Column
nlastrow = xs.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
nlastcol = xs.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
Set theRng = xs.Range(xs.Cells(nFirstRow, nFirstCol), _
xs.Cells(nlastrow, nlastcol))
Exit Sub
handleError:
End Sub
cheers,
raj