Sub CATMain()
'Global Declarations
Dim cell
Dim string
Dim bigstring
Dim totalrows
Dim totalcolumns
Dim drwdoc As DrawingDocument
Dim drwsheets As DrawingSheets
Dim drwsheet As DrawingSheet
Dim drwviews As DrawingViews
Dim catView As DrawingView
Dim drwtables As DrawingTables
Dim objExcel
Dim objWorkbook
Dim objSheet
Dim objCell
Dim oSelect as Selection
Dim InputObjectType(0)
Dim status
Set drwdoc = CATIA.ActiveDocument
Set oSelect = drwdoc.Selection
Set drwsheets = drwdoc.Sheets
Set drwsheet = drwsheets.ActiveSheet
Set drwviews = drwsheet.Views
Set drwview = drwviews.ActiveView
Set drwtables = drwview.Tables
'--User input to select table.
InputObjectType(0)="DrawingTable"
status = oSelect.SelectElement3(InputObjectType,"Select Table", _
true,CATMultiSelTriggWhenSelPerf,True)
if (status = "Cancel") then Exit Sub
set drwtable = oSelect.Item(1).Value
'--Define table and extract strings to array.
totalrows = drwtable.NumberOfRows
totalcolumns = drwtable.NumberOfColumns
Dim table()
ReDim table(totalrows, totalcolumns)
For r = 1 to totalrows
For c = 1 to totalcolumns
table(r, c) = drwtable.GetCellString (r, c)
Next
Next
'--Open Excel
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objSheet = objWorkbook.Sheets.Item(1)
'--Populate spreadsheet with values from array.
For r = 1 to totalrows
For c = 1 to totalcolumns
objSheet.Cells(r,c) = table(r,c)
Next
Next