Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Macro in CAA(3DEXPERIENCE 2018x)

Status
Not open for further replies.

Korawit P

Computer
Feb 17, 2022
1
Hi, I'm extremely new to this field. I'm trying to use CAA to call VBA Macro (It's V6) from Macro library existed in the server CATScriptUtilities::ExecuteScriptV6. The API result was S_OK but result was not what I expected. The returned CATVariant vOutput variable was some random thing(I check it by VARTYPE and it change randomly each execute ). I'm expecting the ExecuteScriptV6 function to return me a VT_BSTR type so I can later convert to string. Is there something I messed up? Or some workaround could be very grateful.

Here're some simplify version of the code

CAA c++ code :
const int iParamCount = 1;
CATVariant iParams[iParamCount];

BuildVariant(usViewName, iParams[0]);

CATVariant vOutput;
VARTYPE vt;
hr = CATScriptUtilities::ExecuteScriptV6(*ipiPLMId, catScriptLibraryTypeVBAProject, "MyModule", vOutput, "MyFunc", iParams, iParamCount);
if (SUCCEEDED(hr)) // S_OK
{
vt = V_VT(&vOutput);
if (vt == VT_BSTR) // the vt was some random thing
{
CATUnicodeString usOutput = "";
hr = ConvertVariant(vOutput, usOutput);
if (SUCCEEDED(hr))
{
// Do things
}​
}​
}​
VBA code :
Function MyFunc(arg1 As String) As String
MyFunc = arg1 + "RETURNED"​
End Function​


Thank you in advance.
 
Replies continue below

Recommended for you

In V5 documentation for ExecuteScript states that it must be run on a timeout. That means that you should make your call within a CATStateCommand with CATApplication.AddTimeOut

Are there similar requirements stated in V6 documentation?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor