Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table CATDrawing to excel CATIA V5

Status
Not open for further replies.

Sendoacf

Chemical
Jun 10, 2022
8
0
0
ES
Hi, i have a table of holes in CATDrawing and i would like to export it to Excel or to .txt
Thank you
 
Replies continue below

Recommended for you

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

End Sub
 
Status
Not open for further replies.
Back
Top