How to Launch Excel from CATIA V5

One of the biggest reasons for learning CATIA macro programming is to be able to automatically export properties from CATIA to an Excel spreadsheet. Export to Excel is highly useful as you can create custom bills of material (BOMs) or part lists at the click of a button.

The first step to exporting any information from inside CATIA is to be able to launch or open Excel. Use the code shown below or download it here.

Sub CatMain() 
Dim Excel As Object 

     On Error Resume Next 

'if Excel is already running, then get the Excel object 
            Set Excel = GetObject(, "Excel.Application") 
  

            If Err.Number <> 0 Then 
'If Excel is not already running, then create a new session of Excel 

                Set Excel = CreateObject("Excel.Application") 

                  Excel.Visible = True       

            End If 

            'add a new workbook 
                        Excel.Workbooks.Add 
        
'set the workbook as the active document 
        Set WBK = Excel.ActiveWorkbook.Sheets(1) 

End Sub

 

 

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.