×
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

Run CATScript from VBA Application

Run CATScript from VBA Application

Run CATScript from VBA Application

(OP)
HI guys,

I have some problems for example, i do not have problems when i run catscript to define in Geometrical Set (pardocument1.part.InWorkObject = hybridBody1)
but when i write this line in Visual studio i get error, i have same problems with other things :(

So i think to make simple CATScript for this action and run it from my Vba Application in Visual studio, but again i have problems :(

I tried like this
ScPath = "C:\Users\Me\Desktop\Macro_recoring\"
CATIA.SystemService.ExecuteScript(ScPath, INFITF.CatScriptLibraryType.catScriptLibraryTypeDirectory, "Macro22.CATScript", "CATMain", EmptyPar)

Any ideas?

Thx

RE: Run CATScript from VBA Application

This is what I use...

Sub CATMain()

Dim strPath As String
Dim strModule As String
Dim strProcedure As String
Dim varArgs() As Variant 'Use empty array if procedure has no args
'Dim varArgs(2) As Variant 'Or size the array if procedure has args
Dim strMsg As String

'Define where to find the VBA project and what to run inside it.
strPath = "\\XXX\YYY.catvba"
strModule = "MAIN"
strProcedure = "MAIN"

'If the procedure has arguments, define them in the array
'As an example, a Sub with 3 input arguments in the VBA project
'Sub CATMain(iInputfile, iOutputFile, iPart)
'varArgs(0) = "C:\Data\InputData.txt"
'varArgs(1) = "C:\Data\OutputData.txt"
'Set varArgs(2) = CATIA.ActiveDocument.Part

'Launch the VBA project
On Error Resume Next
Call CATIA.SystemService.ExecuteScript(strPath, _
2, strModule, strProcedure, varArgs)
If Err.Number <> 0 Then 'Any number other than zero is an error
'Add your own custom error message to the user
strMsg = "An error occurred while trying to run the macro..."
MsgBox strMsg, 16, "Error"
End If

End Sub

regards,
LWolf

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


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close