i want to run the existing VB.Script(in Desktop foloder) from CATVBA. I tried with some code, but i couldn’t not able to execute it.
Sub Atuoamtion6()
Dim CATIA As Object
Set CATIA = CreateObject(“CATIA.Application”)
Dim productDocument As Object
Set productDocument = CATIA.ActiveDocument
Dim product As Object
Set product = productDocument.product
Dim components As Object
Set components = product.Products
Dim component As Object
Dim componentName As String
Dim macroPath As String
macroPath = "C:Usersmvinot22DesktopPPMCADXX.catvbs" ' Update with your actual macro path
On Error GoTo HandleError ' Add error handling
For Each component In components
' Get the name of the component
componentName = component.Name
' Clear the selection
productDocument.Selection.Clear
' Select the current component
productDocument.Selection.Add component
' Open the component in a new window
CATIA.StartCommand "Open in New Window"
' Execute the CATIA macro using ExecuteFile method
CATIA.SystemService.ExecuteFile macroPath
' Close the new window
CATIA.ActiveWindow.Close
Next component
Exit Sub
HandleError:
MsgBox “Error executing script: ” & Err.Description
Resume Next ‘ Continue to the next component or exit the loop
End Sub
Also tried with
' Execute the CATVBS script using Shell
Shell "wscript.exe " & scriptPath
' Execute the CATVBS script
Dim scriptPathVariant As Variant
scriptPathVariant = CStr(scriptPath) ' Ensure it's a string
CATIA.SystemService.ExecuteScript scriptPathVariant, Null