ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Crerating a temporary menu button (https://www.excelbanter.com/excel-programming/273080-re-crerating-temporary-menu-button.html)

steve

Crerating a temporary menu button
 
Lionel,

Put this cose in the ThisWorkbook module

Sub Auto_Close()
On Error Resume Next
' in case there isn't a bar to delete
Application.CommandBars("worksheet menu bar").Delete
End Sub

It's also a good idea to have
Application.CommandBars("worksheet menu bar").Delete
at the beginning of the code that creats the bar in the first place.
(Just in case a version already exists).

steve

"Lionel Fridjhon" wrote in message
...
am trying to create a menu button that is deleted when
the workbook is closed.

I have the following piece of code that puts the button
in place, but it remains in the worksheet toolbar when I
close:

Set ComBar = CommandBars("worksheet menu bar")
With ComBar
.Controls.Add(Type:=msoControlButton,
temporary:=True, befo=6).Caption = "&Process CLiMET"
.Controls("Process CLiMET").Style =
msoButtonCaption
.Controls("PROCESS CLIMET").OnAction
= "SelectFolderToProcess"
End With

Can anyone help?

Lionel





All times are GMT +1. The time now is 03:12 PM.

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