Run time error 91, object vaiable .....

smiler44

Registered User.
Local time
Today, 11:05
Joined
Jul 15, 2008
Messages
671
I'm getting a Run time error 91, object variable or block with variable not set message.

My code is :-

Code:
Private Sub Workbook_Open()
If Sheet1.CheckBox1.Value = True Then
CommandBars("custom 1").Controls("button1").Enabled = False
end if
end sub

I'm assuming I need to declare something as an object but I'm not sure if it is the button or command bar and I dont know how.

The advice is?

Thank you
smiler44
 
Sorted. This was a work around I was trying to create to my excel 2003 custom toolbar buttons not holding their state when the workbook was closed and reopend in excel 2007. I have cracked the problem. It is a quirk of Excel 2007 not liking the code of Excel 2003.
The problem was the code in the Thisworkbook, workbook, beforeclose area. I was using toolbars("toolbar_name").delete this works in Excel 2003 but have had to change it to
toolbars("toolbar_name").visible.false. initial testing seems to have the same effect in that the toolbar is not accessible by other workbooks and my command buttons hold the enabled/disabled state that they are in when the wookbook is closed.

smiler44
 

Users who are viewing this thread

Back
Top Bottom