Contact US

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!

*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

Run a macro from another one

Run a macro from another one

Run a macro from another one

Hi everyone!!

As the SelectElement function is not supported in VBA, I am trying to call a VBScript from VBA and vice-versa.

Is that possible?.... (for example with Create Object or so?)


RE: Run a macro from another one

I don't know CATIA V5 and then CAA programming.
But, I know well VBA in other applications. Just an example, calling from VBscript a VBA subroutine recorded as a macro in a EXCEL sheet :

' Launch EXCEL and get the corresponding application object
Set ObjScript = CreateObject("Excel.Application")
' If you want to see EXCEL openned
ObjScript.Visible = True

' Loading of the workbook containing the macro
Call ObjScript.workbooks.open("D:\TRY.xls")
' Calling of the subroutine. I suppose one integer argument is expected
call objscript.run("TRY.xls!Feuil1.MyMacro",15)

' The subroutine is completed then I quit EXCEL
call ObjScript.quit

This code was tested and it is OK.

I'm not sure you can do this in the other direction, i.e. call and use of an VBscript object from VBA. I think you can only launch a VB script from VBA by using "shell" or "appactivate" function.

But I suppose you can use this principles for calling between to VBA.

RE: Run a macro from another one

Hi everyone!
Thanks to HBP, who answered last time.

I have a new problem now... It´s about programming... When you double click on the specificattions tree of a Product, the active component changes and the name of the component appears with a blue background...

Depending on which was the active component before launching my macro, the "Delete" or "Copy" methods of my macro are allowed or not, and consequently an error appears or not...

So I want to set the active component with code, so that before calling to ".Delete", the blue square is where I want...

Is that possible?

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! Already a Member? Login


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