×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Catia macro from Excel macro

Catia macro from Excel macro

Catia macro from Excel macro

(OP)
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 --> VBA

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 
 
Call CATIA.Module_Excel.recup_donnee
End Sub 
It's the yellow ligne who give me problem.
If you have any idees thanks.

RE: Catia macro from Excel macro

check this

Eric N.
indocti discant et ament meminisse periti

RE: Catia macro from Excel macro

also this

Eric N.
indocti discant et ament meminisse periti

RE: Catia macro from Excel macro

(OP)
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

RE: Catia macro from Excel macro

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

RE: Catia macro from Excel macro

(OP)
Thanks for your help, below the final code :

CODE --> VBA

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 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources