Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Catia macro from Excel macro 1

Status
Not open for further replies.

Kant1

Mechanical
Feb 17, 2015
8
FR
Hello,
I'm programming two macro. One on CATIA and the other on Excel. What I want is that the Excel macro call the CATIA macro but currently I don't how to do that, the only think I'm doing is to open CATIA and my CATPart from Excel.
This is my code in Excel macro :
Code:
Sub CATIA_liaison() 
 
 Dim CATIA As Object 
  
  
On Error Resume Next 
  
Set CATIA = GetObject(, "CATIA.Application") 
  
If Err.Number <> 0 Then 
  
        MsgBox ("Veuillez lancer CATIA.") 
  
End If 
  
On Error GoTo 0 
 
 
CATIA.Documents.Open (nom_fichier) 
CATIA.Visible = True 
 
[highlight #C4A000]Call CATIA.Module_Excel.recup_donnee[/highlight]
End Sub
It's the yellow ligne who give me problem.
If you have any idees thanks.
 
Replies continue below

Recommended for you

Thanks for your help.
It's almost what I want to do. My CATIA macro was written in VBA not in VBScript so do you how to deal with that ?
Thanks
 
Set CATSS = CATIA.SystemService

Dim strProject, strModule, strSub As String

strProject = "c:\temp\VBAProject1.catvba"
strModule = "Module1"
strSub = "CATMain"

Dim params()

X = CATSS.ExecuteScript(strProject, CatScriptLibraryType.catScriptLibraryTypeVBAProject, strModule, strSub, params)


Eric N.
indocti discant et ament meminisse periti
 
Thanks for your help, below the final code :

Code:
Dim sFilePath As String
Dim sFileName As String
Dim sModule As String
Dim sProcedure As String
Dim sFilePathAndName As String
Dim CATIA As Object
Dim CatSysServ As Variant
Dim Params() As Variant
Dim vRetVal As Variant

'Everything here is Case-Sensitive
sFilePath = Path & "\"
sFileName = "Macro_2_Zones.catvba"
sModule = "Module_Excel"
sProcedure = "CATMain" 'CatMain is only allowable Choice

'Concate File Path and Name
sFilePathAndName = sFilePath & sFileName

Set CATIA = GetObject(, "CATIA.Application")
Set CatSysServ = CATIA.SystemService

Application.DisplayAlerts = False

vRetVal = CatSysServ.ExecuteScript(sFilePathAndName, catScriptLibraryTypeVBAProject, sModule, "CATMain", Params)
Application.DisplayAlerts = True

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top