Click here to Skip to main content
15,888,733 members
Posted
Updated 6-Sep-13 23:30pm
v2
Comments
moon_lu 7-Sep-13 4:26am    
Does anybody know how to implement an asynchronous function in Excel 2003? Here is what I want to achieve: after the function is called, return "calculating" to the calling cell, and start calculation. When the calculation finishes, refresh the cell to display the result (note: the return value of the async function is changed but the formula is not).
Richard MacCutchan 7-Sep-13 5:32am    
If there is, then google should find it for you.

1 solution

VARIANT _stdcall AAs(BSTR pfieldlist)
{

::CoInitialize(NULL);
VARIANT v;v.vt = VT_BSTR;
CComQIPtr<msexcel::_application xmlns:msexcel="#unknown"> spApp(g_Application);

long a = spApp->ThisCell->Row;
long b = spApp->ThisCell->Column;
a++;
CString str;
str.Format("a = %d b = %d",a,b);
OutputDebugString(str);

try {
v= spApp->WorksheetFunction->RTD("Test1.AA.1","",_variant_t(L"AAA"),_variant_t((long)a),_variant_t((long)b);
OutputDebugString("In");
}
catch (CException ex)
{
char szMaxErr[1024] = {0};
ex.GetErrorMessage(szMaxErr, 1024);
OutputDebugString(szMaxErr);
}
return v;

}
The RTD embeded into the UDF,which can realize the async.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900