ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Invoking Range.SpecialCells using IDispatch.Invoke (https://www.excelbanter.com/excel-programming/432742-invoking-range-specialcells-using-idispatch-invoke.html)

Raja

Invoking Range.SpecialCells using IDispatch.Invoke
 
Hi,

I'm writing a method in XLL add-in for excel 2007 using the ComInterop to
call Range.SpecialCells using iDispatch.Invoke. but how I can pack the
XlCellType as Variant?
I've tried to provide the int value of the enum but it didn't work:

....
VariantInit(&lCellType);
lCellType.vt = VT_INT;
lCellType.intVal = -4123;
hr = AutoWrap(DISPATCH_METHOD,&lResult, pCellRef/*pionter to Range*/,
L"SpecialCells", &lCellType);

Any idea?

Regards,
Raja

joel

Invoking Range.SpecialCells using IDispatch.Invoke
 
Go to vba window in excel and select menu view - Object Browser.

In the object browser box next to the binoculars put in xlcelltype and press
the binoculars to perform a search.

You can now click on any of the types such as xlCellTypeAllFormatConditions.
You will see the interger value sof each of the types.

xlCellTypeAllFormatConditions = -4172 (&HFFFFEFB4)
xlCellTypeAllValidation = -4174 (&HFFFFEFB2)
xlCellTypeBlanks = 4
xlCellTypeComments = -4144 (&HFFFFEFD0)
xlCellTypeConstants = 2
xlCellTypeFormulas = -4123 (&HFFFFEFE5)
xlCellTypeLastCell = 11
xlCellTypeSameFormatConditions = -4173 (&HFFFFEFB3)
xlCellTypeSameValidation = -4175 (&HFFFFEFB1)
xlCellTypeVisible = 12

I'm not sure how an integer and long are defined in your software. You ned
to reserve 16 bits for the parameter. The xlcelltype is required for the
function. It is not a variant. The xlcelltype is the format of the data you
want to copy.




"Raja" wrote:

Hi,

I'm writing a method in XLL add-in for excel 2007 using the ComInterop to
call Range.SpecialCells using iDispatch.Invoke. but how I can pack the
XlCellType as Variant?
I've tried to provide the int value of the enum but it didn't work:

...
VariantInit(&lCellType);
lCellType.vt = VT_INT;
lCellType.intVal = -4123;
hr = AutoWrap(DISPATCH_METHOD,&lResult, pCellRef/*pionter to Range*/,
L"SpecialCells", &lCellType);

Any idea?

Regards,
Raja



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

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