ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a menu in code (https://www.excelbanter.com/excel-programming/354499-creating-menu-code.html)

James D.

Creating a menu in code
 
I have VBA code that create's a new menu bar called "Process". The Code is
run when the worksheet opens. Problem is that it creates the menubar each
time the worksheet opens thus giving me multiple identicle menus. I need
some code to test to see if the menu has indeed been created, and if so not
to create it again. I have tried several different things with no luck. Any
help would be greatly appreciated.

Thanks in advance.

James D.

Tom Ogilvy

Creating a menu in code
 
Dim cb as Commandbar
On error resume next
set cb = Commandbars("Process")
On Error goto 0
if cb is nothing then
' create Process commandbar
end if

If Process is not a commandbar, but a button or something, just adjuste the
code, but the approach is the same.

--
Regards,
Tom Ogilvy

"James D." wrote in message
...
I have VBA code that create's a new menu bar called "Process". The Code

is
run when the worksheet opens. Problem is that it creates the menubar

each
time the worksheet opens thus giving me multiple identicle menus. I need
some code to test to see if the menu has indeed been created, and if so

not
to create it again. I have tried several different things with no luck.

Any
help would be greatly appreciated.

Thanks in advance.

James D.




Bob Phillips[_6_]

Creating a menu in code
 
Before creating it, just delete it regardless

On Error Resume Next
Application.Commandbars("Process").Delete
On Error Goto 0

'now create anew

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"James D." wrote in message
...
I have VBA code that create's a new menu bar called "Process". The Code

is
run when the worksheet opens. Problem is that it creates the menubar

each
time the worksheet opens thus giving me multiple identicle menus. I need
some code to test to see if the menu has indeed been created, and if so

not
to create it again. I have tried several different things with no luck.

Any
help would be greatly appreciated.

Thanks in advance.

James D.




James D.

Creating a menu in code
 
Many thx, this is what I needed.

"Bob Phillips" wrote:

Before creating it, just delete it regardless

On Error Resume Next
Application.Commandbars("Process").Delete
On Error Goto 0

'now create anew

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"James D." wrote in message
...
I have VBA code that create's a new menu bar called "Process". The Code

is
run when the worksheet opens. Problem is that it creates the menubar

each
time the worksheet opens thus giving me multiple identicle menus. I need
some code to test to see if the menu has indeed been created, and if so

not
to create it again. I have tried several different things with no luck.

Any
help would be greatly appreciated.

Thanks in advance.

James D.





James D.

Creating a menu in code
 
Many thx, this is what I needed.

"Tom Ogilvy" wrote:

Dim cb as Commandbar
On error resume next
set cb = Commandbars("Process")
On Error goto 0
if cb is nothing then
' create Process commandbar
end if

If Process is not a commandbar, but a button or something, just adjuste the
code, but the approach is the same.

--
Regards,
Tom Ogilvy

"James D." wrote in message
...
I have VBA code that create's a new menu bar called "Process". The Code

is
run when the worksheet opens. Problem is that it creates the menubar

each
time the worksheet opens thus giving me multiple identicle menus. I need
some code to test to see if the menu has indeed been created, and if so

not
to create it again. I have tried several different things with no luck.

Any
help would be greatly appreciated.

Thanks in advance.

James D.






All times are GMT +1. The time now is 05:13 PM.

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