The CATVBA code I am trying to launch is a Macro Menu I have created and shared with my department.
The Macro is an Icon on everyone's toolbar.
The issue I have is that I can't modify the Macro Menu because it is being referenced by everyone in my department when Catia launches.
So if I put a buffer in there to the only time it is referenced, is when the CATScript calls it to open, I could modify the Macro Menu it at any point.
DraftingUtility is the name of my VBA code. Vbmodeless allows it to launch and let the user still work/make selections in catia. The opposite, not allowing any slections in CATIA is Vbmodal. I use this for your exact application, it opens a userform that has many different macros for V5.
Dim ProjPath As String
Dim strModule As String
Dim strProcedure As String
'Dim varArgs() As Variant 'Use empty array if procedure has no args
Dim varArgs(0) 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.
ProjPath = "C:\temp\PROJECT.catvba"
strModule = "MainModule"
strProcedure = "CATMain"
'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) = InputFile.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(ProjPath, _
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