run time error using commandbar during before close

M

mango

Dear All, why beforeclose i got this message at set cmd = commandbars("Tender
Bar")
run time error 91
object variable or with block variable not set?

click commandbutton works fine.
pls help.
thanks



Private Sub Workbook_BeforeClose(Cancel As Boolean)
disable
End Sub

Sub disable()
Dim cmd As CommandBar
Set cmd = CommandBars("Tender Bar")
cmd.Controls("&KC").Enabled = False
End Sub


Private Sub CommandButton1_Click()
enable
End Sub

Sub enable()
Dim cmd As CommandBar
Set cmd = CommandBars("Tender Bar")
cmd.Controls("&KC").Enabled = True
End Sub
 
M

mango

dear frank, it works! thanks alot. u r great!
what is the different between set cmd = commandbars("XX")
and set cmd = application.commandbars("XX") ??
 
F

Frank Kabel

Hi
it is just the full specification of the object reference. Always
better to do this
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top