ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   addin problem: sheet mismatch by function parameters (https://www.excelbanter.com/excel-programming/285262-addin-problem-sheet-mismatch-function-parameters.html)

berrie

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....



All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com