excel - Error: Unable to get the AutoFilter property of the Range class -



excel - Error: Unable to get the AutoFilter property of the Range class -

in next code, receive above-named error, only on sec phone call autofilter().

string filtervalue1 = tbsyscat1.text.filterdoesnotcontain(); string filtervalue2 = tbsyscat2.text.filterdoesnotcontain(); string filtervalue3 = tbsyscat3.text.filterdoesnotcontain(); string[] syscat = new string[6]; // edit: tried object[]; still got error syscat[0] = filtervalue1; syscat[1] = filtervalue1.toupper(); syscat[2] = filtervalue2; syscat[3] = filtervalue2.toupper(); syscat[4] = filtervalue3; syscat[5] = filtervalue3.toupper(); vapplication.activesheet.range[vworkingrange].autofilter(9, missing.value, missing.value, missing.value, true); vapplication.activesheet.range[vworkingrange].autofilter(9, syscat, msexcel.xlautofilteroperator.xlfiltervalues, missing.value, true);

note: filterdoesnotcontain() extension method add together excel-specific wildcards "does not contain".

from other research, error indicates autofilter not associated range object @ runtime (since dynamic type). however, associated fine in first call. that's baffling part.

the first phone call there clear filter column 9.

environment: vsto in vs2010 using .net 4.0 (edit: ms excel 2007 pro)

appreciate help!

i sorry, don't have excel seek out. however, alter next line

vapplication.activesheet.range[vworkingrange].autofilter(9, missing.value, missing.value, missing.value, true);

to

vapplication.activesheet.range[vworkingrange].autofilter(missing.value, missing.value, missing.value, missing.value, missing.value);

or

vapplication.activesheet.range[vworkingrange].autofilter();

this way clear autofilter. i.e. when click on auto filter button, columns filter , not specific one. result, have clear auto filter (by not telling column).

edit: in case helps, generate macro of wanting in vba. if works, translate c#.

edit: add together multiple criteria, can reference activesheet.autofilter property (once auto filter in effect). property, can farther criterias.

take @ page, filters collection can add together criterias using filters.add.

excel vsto autofilter

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -