tkaplan
11-16-2005, 07:40 AM
I have a worksheet that has a button named cmdTrend. i am trying to write code that depending on certain conditions, the button changes to visible and not visible.
i currently have:
'sheet and workbook are unprotected
if <<condition=true>> Then
'i put this line in to try and see if it would make a difference
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.Shapes("cmdTrend").Select
Selection.Visible = True
Application.CommandBars("Control Toolbox").Visible = False
Else
If ActiveSheet.Shapes("cmdTrend").Visible = True Then
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.Shapes("cmdTrend").Select
Selection.Visible = False
Application.CommandBars("Control Toolbox").Visible = False
End If
End If
Half of this works - if the button is visible and the condition is false, it sets the button to invisible. however, if the botton is not visible and the condition is true, i receive the following error:
Method 'select' of object 'shapes' failed.
I figure that what is going on is it cant find the shape b/c it is not visible. How can i fix this?
Thanks in advance.
tkaplan
i currently have:
'sheet and workbook are unprotected
if <<condition=true>> Then
'i put this line in to try and see if it would make a difference
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.Shapes("cmdTrend").Select
Selection.Visible = True
Application.CommandBars("Control Toolbox").Visible = False
Else
If ActiveSheet.Shapes("cmdTrend").Visible = True Then
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.Shapes("cmdTrend").Select
Selection.Visible = False
Application.CommandBars("Control Toolbox").Visible = False
End If
End If
Half of this works - if the button is visible and the condition is false, it sets the button to invisible. however, if the botton is not visible and the condition is true, i receive the following error:
Method 'select' of object 'shapes' failed.
I figure that what is going on is it cant find the shape b/c it is not visible. How can i fix this?
Thanks in advance.
tkaplan