Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default convert selection variant idispatch to something useful

I have a C++ app that I am converting from using DDE to OLE Automation
to talk with Excel. Does anyone know how to convert a "selection" Variant
of type VT_DISPATCH to something useful like a char string ?

Thanks,
Lynn McGuire


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default convert selection variant idispatch to something useful

Hi.

Could you tell me more about that?
What inconvenience do you feel when you use VT_DISPATCH?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default convert selection variant idispatch to something useful

Could you tell me more about that?
What inconvenience do you feel when you use VT_DISPATCH?


I have no idea how to convert the variant to char * strings:

IDispatch *pDocApp;
{
VARIANT result;
VariantInit ( & result);
OLEMethod (DISPATCH_PROPERTYGET, & result, pXlApp, L"Application", 0);
pDocApp = result.pdispVal;
}
IDispatch *pXlSelection;
{
VARIANT result;
VariantInit ( & result);
OLEMethod (DISPATCH_PROPERTYGET, & result, pDocApp, L"Selection", 0);
pXlSelection = result.pdispVal;
if (result.vt == VT_DISPATCH)
{
IDispatch *pDisp = result.pdispVal;
// how to convert this idispatch pointer to char * strings now ???
}
}

Thanks,
Lynn
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default convert selection variant idispatch to something useful

I have no idea how to convert the variant to char * strings:

Figured it out:

{
VARIANT result;
VariantInit ( & result);
OLEMethod (DISPATCH_PROPERTYGET, & result, pXlApplication, L"Selection", 0);
if (result.vt == VT_DISPATCH)
{
IDispatch *pDisp = result.pdispVal;
// this will get the contents of the selected cell
// VariantInit ( & result);
// OLEMethod (DISPATCH_PROPERTYGET, & result, pDisp, L"Value", 0);
// int res_value = result.vt;
// this will get the address of the selected cell
VariantInit ( & result);
OLEMethod (DISPATCH_PROPERTYGET, & result, pDisp, L"Address", 0);
if (result.vt == VT_BSTR)
selection = _bstr_t (result.bstrVal);
pDisp - Release ();
}
}

Thanks,
Lynn
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using created variant value to reference to a variant within my code TD[_3_] Excel Programming 1 April 22nd 09 11:53 AM
Convert values in a variant array to integer values Graham McNeill Excel Programming 1 November 13th 04 12:47 AM
Excel iDispatch problem Excel iDispatch problem Excel Programming 0 June 30th 04 12:28 PM
different IDispatch in event handler Dirk[_2_] Excel Programming 0 January 23rd 04 11:04 PM
variant array containing cel adresses convert to actual ranges-array Peter[_21_] Excel Programming 5 December 10th 03 09:50 PM


All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"