View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
berrie berrie is offline
external usenet poster
 
Posts: 2
Default addin problem: sheet mismatch by function parameters

I'm programming in visual c++ 6.0 and using microsoft excel 2002 servicepack 2.
I have made a addin for excel. The TestFunction is called by using the wizard. The TestFunction is called, with the following values:

Values for the Cells.
cell1 = sheet1.A1
cell2 = sheet1.A2
cell3 = sheet2.A5

The worksheets that i get from Cell1 and Cell2 are wrong. Im getting from Cell1 and Cell2, the same sheet as cell3. This only occurs if the code: €śrange.GetStyle€ť is executed.

STDMETHODIMP KFunctions::TestFunction (VARIANT* cell1, VARIANT* cell2, VARIANT* cell3, VARIANT* obj)
{
if (cell1 == NULL)
return (false);
if (cell1-vt != VT_DISPATCH)
return (false);
EXCEL_EXT::Range range (cell1-pdispVal);
EXCEL_EXT::_Worksheet ws (range.GetParent());
CString name = ws.GetName();
TRACE ("cell 1 = %s\n", name);
VARIANT tmp = range.GetStyle (); //this line is the problem
}

return values from Cells.
cell1 becomes sheet2
cell2 becomes sheet2
cell3 stays sheet2

Does anyone know how to resolve this problem....