Code:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CATIA
Dim Doc
Dim outFile
Dim outStream
Dim STATUS
Dim rowSize
Dim columnSize
Dim tmp_output
CATIA = GetObject(, "CATIA.application")
Doc = CATIA.ActiveDocument
outFile = CATIA.FileSystem.CreateFile("C:\users\" & CATIA.SystemService.Environ("USERNAME") & "\desktop\TableFile.csv", True)
outStream = outFile.OpenAsTextStream("ForWriting")
Dim oType(0)
oType(0) = "DrawingTable"
STATUS = CATIA.ActiveDocument.Selection.SelectElement2(oType, "please select the table to extract", False)
If status = "Cancel" Then Exit Sub
Dim oTable
oTable = CATIA.ActiveDocument.Selection.Item(1).Value
outStream.Write(oTable.Name & Chr(10))
rowSize = oTable.NumberOfRows
columnSize = oTable.NumberOfColumns
For row = 1 To rowSize
tmp_output = ""
For column = 1 To columnSize
tmp_output = tmp_output & oTable.GetCellString(row, column) & ";"
Next
outStream.Write(tmp_output & vbCrLf)
Next
outStream.Close()
MsgBox("Ausgabe beendet")
End Sub
End Class