Advertisement
Guest User

Untitled

a guest
May 19th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub CATMain()
  2.  
  3. Dim MyDrawingDocument As Document
  4.  
  5. Dim MyDrawingSheets As DrawingSheets
  6. Dim MyDrawingSheet As DrawingSheet
  7.  
  8. Dim MyDrawingViews as DrawingViews
  9. Dim MyDrawingView as DrawingView
  10.  
  11. Dim MyDrawingTables as DrawingTables
  12. Dim MyDrawingTable as DrawingTable
  13.  
  14. Dim NumberOfSheet
  15. Dim NumberOfView
  16. Dim NumberOfTable
  17. Dim Rows
  18. Dim Columns
  19. Dim Row
  20. Dim Column
  21.  
  22.  
  23.  
  24.  
  25. Set MyDrawingDocument = CATIA.ActiveDocument
  26. Set MyDrawingSheets = MyDrawingDocument.Sheets
  27.  
  28.         For NumberOfSheet = 1 To MyDrawingSheets.Count
  29.        
  30.         Set MyDrawingSheet = MyDrawingSheets.Item(NumberOfSheet)
  31.         Set MyDrawingViews = MyDrawingSheet.Views
  32.  
  33.                         For NumberOfView = 1 To MyDrawingViews.Count
  34.                         Set MyDrawingView = MyDrawingViews.Item(NumberOfView)
  35.                         Set MyDrawingTables = MyDrawingView.Tables
  36.  
  37.                                     For NumberOfTable=1 To MyDrawingTables.Count
  38.                                     Set MyDrawingTable = MyDrawingTables.Item(NumberOfTable)
  39.                                     Rows = MyDrawingTable.NumberOfRows
  40.                                     Columns = MyDrawingTable.NumberOfColumns
  41.                                     Dim ArrayToExport
  42.                                     ReDim ArrayToExport (Rows,Columns)
  43.                                            
  44.                                                         For Row = 1 To Rows
  45.                                                                     For Column = 1 To Columns
  46.                                                                     ArrayToExport(Row, Column) = MydrawingTable.GetCellString(Row, Column)
  47.                                                                     Next
  48.                                                         Next
  49.                                     'Send an array to excel
  50.                                        MsgBox "Table has been exported to excel."
  51.                                         Dim MyObjectExcel
  52.                                         Set MyObjectExcel = CreateObject("Excel.Application")
  53.                                         MyObjectExcel.Visible =True
  54.                                         Set MyObjectWorkbook = MyObjectExcel.Workbooks.Add()
  55.                                         MyObjectWorkbook.Activate
  56.                                         Set MyObjectSheet = MyObjectWorkbook.Worksheets.Item(1)
  57.  
  58.  
  59.                                                 For Row = 1 To Rows
  60.  
  61.                                                     For Column = 1 To Columns
  62.                                                     MyObjectSheet.Cells(Row, Column) = ArrayToExport(Row, Column)
  63.                                                     Next
  64.  
  65.                                                 Next
  66.  
  67.                                    
  68.  
  69.                                     Next
  70.  
  71.  
  72.                         Next
  73.         Next
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement