LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I AutoFilter a column in Excel in CVI

How do I filter a column in an Excel worksheet. I am aware that there is an activeX function Excel_RangeAutoFilter(). But I am not sure of the parameters to be passed to this function. Please help me.
 
Regards
Lakshmi
0 Kudos
Message 1 of 4
(3,690 Views)
Hi Lakshmi,

You can find more information about the Excel_RangeAutoFilter() ActiveX function on MSDN under Range.AutoFilter Method.  I think you will find all the information you were looking for there.


Jessica
National Instruments
Product Support Engineer
0 Kudos
Message 2 of 4
(3,655 Views)
Thanks for the reply. But now when I call the function Excel_RangeAutoFilter () I am getting error "No such interface supported'. I have pasted the copy of the code below. My aim is to autofilter column 2 of the workbook as nonblanks.
 
int Auto_Code_Excel_ResetAutoFilter(void)
{
 
     HRESULT errorCode      = 0;
     char errorBuffer[256]  = {0};
     unsigned int bufferSize= 256;
     VARIANT field;
     VARIANT criteria1;
     VARIANT criteria2;
     VARIANT visibleDropDown;
     VARIANT returnValue;
     int ret = 0;

     CA_VariantSetEmpty (&field); 
     CA_VariantSetEmpty (&criteria1); 
     CA_VariantSetEmpty (&criteria2);
     CA_VariantSetEmpty (&visibleDropDown); 
     CA_VariantSetBool(&visibleDropDown,0);
     CA_VariantSetUInt (&field, 2);
     CA_VariantSetCString( &criteria1, "<>");
     CA_VariantSetCString( &criteria2, "<>");
     CA_VariantSetIntPtr(&returnValue,&ret);

     errorCode = Excel_RangeAutoFilter (workbookHandle,NULL, field,criteria1,ExcelConst_xlOr,criteria2,
                                       visibleDropDown, &returnValue);
 
     CA_GetAutomationErrorString (errorCode, errorBuffer, bufferSize);
     ExcelRpt_WorkbookSave(workbookHandle,"",ExRConst_DefaultFileFormat);

     return 0;
 
}
0 Kudos
Message 3 of 4
(3,558 Views)
Lakshmi,

You may have better luck posting this question in a discussion forum on MSDN as this function is officially supported by them.  Thanks!
Matt S
National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(3,523 Views)