Page 1 of 1

VB to VC automation

Posted: November 5th, 2002, 12:47 pm
by futurenets
I'm using the VB-toVC automation code converter to help me create a dll function that places some text into an excel spreadsheet cell.If I want to send "YES" then it produces: rVal.vt = VT_BSTR;rVal.bstrVal = ::SysAllocString(L"YES");VariantCopy(&xlvalue, &rVal);VariantClear(&rVal);does anyone now how I can specify a variable name in ::SysAllocString instead of "YES"e.g. something like ::SysAllocString(L str);Thanks PW

VB to VC automation

Posted: November 5th, 2002, 1:06 pm
by jens
std::wstring str(L"string I want to pass");...rVal.vt = VT_BSTR;rVal.bstrVal = ::SysAllocString(str);The L prefix tells the compiler that this is a wide/unicode string constant. If you have a char* try the USES_CONVERSION and A2OLE macros.Jens.

VB to VC automation

Posted: November 6th, 2002, 9:59 am
by futurenets
thanks Jens, your help was invaluable.I was using char * and the following worked fine:USES_CONVERSION;rVal.vt = VT_BSTR;rVal.bstrVal = ::SysAllocString(A2OLE(strptr));VariantCopy(&xlvalue, &rVal);VariantClear(&rVal);RegardsPW