Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is there a way to create a check box that you can turn on and off a reference line on a chart?
~Norman Rea
There is standard functionality to conditionally show/hide refrence lines, so I really wouldn't recommend doing this via a macro.
Please see attached
Hope that helps
Joe
Hi,
sure there is. You can wrap the expression for the line inside an IF_expression making it dependent on the value of a variable.
I would advise you to create a "development_variable" that you can use in any app you create and that you can toggle, thus turning such things on or off at will.
HTH
you have some example code for me to understand?
~Norm
ur looking for this?
Well, just use the usual
>> SET v_Dev = 1 <<
to initialize the variable.
Then you can wrap any expression in an IF_clause like
>> = IF(v_Dev = 1,
) <<
You can also make the visibility of any object dependent on that variable. And you can add a button with the expression (to set a variable_value) >> = v_Dev * -1 << - that way, it will be either 1 or -1 and you can toggle it easily.
Hahahaha you are right. It makes me feel so stupid that I thought it was not possible,
Best,
Sunny
..or more advance way.
Add this to Edit Module window and add to buttons
One will create line in your chart the other will remove it
(Change the bit in Green to your values)
sub AddRef
set chart = ActiveDocument.GetSheetobject("CH01")
col = ActiveDocument.GetApplication.GetSolidColorArea(255,0,0) 'red
chart.AddRefLine "50",2,col 'red at 50 on primary y
set p = chart.GetProperties
set rl = p.ChartProperties.RefLines.Item(0)
rl.Style = 0 'solid
chart.SetProperties p
End sub
Sub RemoveRef
set Graph = ActiveDocument.GetSheetObject("CH01")
Graph.RemoveRefLine 0
End sub
There is standard functionality to conditionally show/hide refrence lines, so I really wouldn't recommend doing this via a macro.
Please see attached
Hope that helps
Joe
try this way also,
Where did you define you variable