i've had scan of cannot find solution this.
- i have number of sheets in excel workbook
- each sheet has identical collection of activex togglebuttons
- these toggle buttons control filtering of data in pivot chart.
filtering on "1" or "all" - i want toggle button change colour when clicked.
i have working fine when code connected sheet.
here passing "tgl_butt" button name
d
dim ctrl oleobject activesheet ' ' change button colour ' each ctrl in oleobjects if typename(ctrl.object) = "togglebutton" if ctrl.name = tgl_butt if boovalue = true oleobjects(ctrl.name).object.backcolor = rgb(255, 255, 0) ' in = yellow else oleobjects(ctrl.name).object.backcolor = rgb(184, 204, 228) 'out = blue end if end if end if next ctrl end
i trying put code module can shared worksheets containing toggle buttons.
call do_filter(tgl_but.value, "tgl_name", ctrl)
and in module ..
public sub do_filter(boovalue boolean, tgl_butt string,ctrl oleobject) activesheet dim myctrl 'as oleobject each myctrl in ctrl if typename(myctrl.object) = "togglebutton" if myctrl.name = tgl_butt if boovalue = true ctrl(myctrl.name).object.backcolor = rgb(255, 255, 0) ' in = yellow else ctrl(myctrl.name).object.backcolor = rgb(184, 204, 228) 'out = blue end if end if end if next myctrl end
i "object required" error above code. ctrl object empty ... suppose i've got drastically wrong somewhere! i've tried number of variations code cannot seem work! suggestions welcome!
so, put code in worksheet class, , worked. generalized in module , doesn't work. right?
if that's case reckon:
- the code in worksheet class can access oleobjects sheet.
- the code in module, doesn't have direct access oleobjects collection, since global class not in module..
with code define:
with activesheet
but don't use . part part of with. i.e. useless since not being used. think need qualify object.
so try either activesheet.oleobjects (or place . in front of oleobjects collection if using with).
hope works you.
Comments
Post a Comment