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 :
Thank you in advance.
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
{
VBA code : 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
{
}if (vt == VT_BSTR) // the vt was some random thing
{
CATUnicodeString usOutput = "";
hr = ConvertVariant(vOutput, usOutput);
if (SUCCEEDED(hr))
{
// Do things
}
}hr = ConvertVariant(vOutput, usOutput);
if (SUCCEEDED(hr))
{
// Do things
}
Function MyFunc(arg1 As String) As String
MyFunc = arg1 + "RETURNED"
End FunctionThank you in advance.