Dec 20 2023 05:50 PM
Hi,
I have been trying to write an RTD com server in C++ to display the user defined data. My question here is: Could we send a user defined data type, i.e. Employee, from the RTD server in the callback and unpack in the VBA code?
struct Employee {
int age;
std::string name;
};
HRESULT CNAHERTDServer::RefreshData(long * topicCount, SAFEARRAY * * parrayOut) {
//it works
value.vt = VT_BSTR;
_bstr_t bstrt(itr->second.c_str());
value.bstrVal = bstrt;
SafeArrayPutElement(*parrayOut, index, &value);
}
VBA code: //get employee here, unpack and put in the excel
Private Sub Worksheet_Calculate()
Dim changedRange As Range
On Error Resume Next
Set changedRange = Range("Lookup!tbData")
On Error GoTo 0
If Not changedRange Is Nothing And changedRange.Count = 1 Then
Debug.Print changedRange.value
End If
End Sub
Thanks
Aug 20 2024 07:01 AM