C
Craig Brandt
I have a button on a sheet that was initially generated with the following
code:
Public StratAFBut As Button
Sheets("Strat").Select
Set StratAFBut = ActiveSheet.Buttons.Add(2, 2, 100, 28)
StratAFBut.Caption = "Turn AutoFocus On"
StratAFBut.OnAction = "AutoFocusStrat"
When I depress the button, I want to toggle the caption on the button as
follows:
StratAFBut.Caption = "Turn AutoFocus On"
Else
StratAFBut.Caption = "Turn AutoFocus Off"
When I first fire up the worksheet, this works, but when I go off and do
something else on the worksheet, then come back, it fails.
Run-time error '91':
Object Variable or With block variable not set.
What am I missing?
Thanks,
Craig
code:
Public StratAFBut As Button
Sheets("Strat").Select
Set StratAFBut = ActiveSheet.Buttons.Add(2, 2, 100, 28)
StratAFBut.Caption = "Turn AutoFocus On"
StratAFBut.OnAction = "AutoFocusStrat"
When I depress the button, I want to toggle the caption on the button as
follows:
StratAFBut.Caption = "Turn AutoFocus On"
Else
StratAFBut.Caption = "Turn AutoFocus Off"
When I first fire up the worksheet, this works, but when I go off and do
something else on the worksheet, then come back, it fails.
Run-time error '91':
Object Variable or With block variable not set.
What am I missing?
Thanks,
Craig