ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   commandbar at workbook before close - run time error (https://www.excelbanter.com/excel-programming/314514-commandbar-workbook-before-close-run-time-error.html)

tango

commandbar at workbook before close - run time error
 
Dear Frank, I do not understand your reply. why you said duplicate?
can explain. thanks alot


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

Tom Ogilvy

commandbar at workbook before close - run time error
 
set cmd = Application.commandbars("Tender Bar")

--
Regards,
Tom Ogilvy


"tango" wrote in message
om...
Dear Frank, I do not understand your reply. why you said duplicate?
can explain. thanks alot


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





All times are GMT +1. The time now is 01:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com