VBA CATIA - Using the startcommand function

Hi all

I have been desperately looking for several days for a solution to my problem which is the following:

I am developing a VBA interface under CATIA that allows you to create folders in particular locations and with standard names. My problem is not in this part but rather in the next step. Indeed, I want to register my product with a directory propagation, the only solution I have found to perform this task is to use the following code: CATIA. StartCommand "Records Management"

The problem is that I can work with several CATIA sessions open, in which case the code I created, even if it is executed from the desired session, will run on the first CATIA session that was opened.

So I want to know if it is possible to execute the command in the desired session and how to do it in this case.

The snippet of code concerned by my problem is the following:

Sub Gestion_enregistrement()

Dim objApplication As Object
Set objApplication = GetObject(, "CATIA. Application")
objApplication.Visible = True

objApplication.StartCommand "Records Management"

End Sub

I simplified it to keep only the essentials, the goal is really to execute the command in the CATIA session which is in the foreground of Windows.

Thank you in advance for your help.

Hello

Here is a code that seems to meet your expectations (or at least what I understood)

I just changed a line very slightly

Have a nice day

Sub Gestion_enregistrementVersion()

    Dim objApplication As Object

    Set objApplication = CATIA. Application
    objApplication.Visible = True
    objApplication.StartCommand "Records Management"

End Sub

 

Hello

Sorry for the delay in replying. Your proposal seems to work, it was indeed my way of declaring Catia that was the problem.

Thank you and have a good day.