LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Test to see if custom menu exists

set an object to the button and then check to see if the object exists or
not... something like this...

dim cmd as commandbarcontrol

on error resume next
set cmd = Application.CommandBars("Worksheet
menubar").Controls("Tools").Controls("Baselines")
on error goto 0

if cmd is nothing then
Application.CommandBars("Worksheet men
bar").Controls("Tools").Controls.Add(Type:=msoCont rolPopup).Caption =
"Baselines"
end if

--
HTH...

Jim Thomlinson


"Kent McPherson" wrote:

I have a spreadsheet where I create a custom menu added to the Tools menu
when the workbook is opened. In the ThisWorkBook object, in the Sub
Workbook_Open(), I have code that looks something like:

Application.CommandBars("Worksheet men
bar").Controls("Tools").Controls.Add(Type:=msoCont rolPopup).Caption =
"Baselines"

The menu is deleted when the workbook is closed by the Sub
Workbook_BeforeClose(Cancel As Boolean) routine. This all works great.
But if I open another workbook that has different data but the same macros,
I get another copy of the Baselines menu. How can I check to see if the
menu already exists and skip the creation/deletion step appropriately?

Thanks!



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test if file exists Daniel Bonallack Excel Discussion (Misc queries) 2 May 4th 09 04:19 PM
How to test if a DLL (library) exists ExcelMonkey Excel Programming 2 August 7th 05 08:14 PM
Test for Worksheet Exists bcmiller[_8_] Excel Programming 4 July 2nd 04 11:46 AM
Test if folder exists, create if it doesn't? 43fan Excel Programming 1 March 1st 04 04:31 PM
Test if a folder exists Jeff Marshall Excel Programming 6 September 30th 03 05:21 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"