PC Review


Reply
Thread Tools Rate Thread

Disable Menu (CommandBar) if not workbook is opened

 
 
LuisE
Guest
Posts: n/a
 
      25th Dec 2007
I have a menu from an Add-In, when all workbooks are closed and all the other
menus are disabled mine remains enabled.
How can I disabled it so if someone clicks it no error message is generated?
Just as the built-in ones.

Thanks in advance

 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      26th Dec 2007
Do you create the menu with VBA code ?

You can create the menu in the Open even and close it in the beforeclose event
See this example

Debra Dalgleish's (Toolbar example from Dave Peterson)
http://www.contextures.com/xlToolbar02.html


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"LuisE" <(E-Mail Removed)> wrote in message news:9AE031B5-1918-423E-9A5A-(E-Mail Removed)...
>I have a menu from an Add-In, when all workbooks are closed and all the other
> menus are disabled mine remains enabled.
> How can I disabled it so if someone clicks it no error message is generated?
> Just as the built-in ones.
>
> Thanks in advance
>

 
Reply With Quote
 
LuisE
Guest
Posts: n/a
 
      26th Dec 2007
Thanks Ron, merry Christmas by the way.

Yes I did.
My concern is that the Add-In will remain installed even if not workbook in
opened so I'd imagine that it is technically not closed, is it?



"Ron de Bruin" wrote:

> Do you create the menu with VBA code ?
>
> You can create the menu in the Open even and close it in the beforeclose event
> See this example
>
> Debra Dalgleish's (Toolbar example from Dave Peterson)
> http://www.contextures.com/xlToolbar02.html
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "LuisE" <(E-Mail Removed)> wrote in message news:9AE031B5-1918-423E-9A5A-(E-Mail Removed)...
> >I have a menu from an Add-In, when all workbooks are closed and all the other
> > menus are disabled mine remains enabled.
> > How can I disabled it so if someone clicks it no error message is generated?
> > Just as the built-in ones.
> >
> > Thanks in advance
> >

>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      26th Dec 2007
A add-in will close when you close Excel.

Can you explain more what you want ?
Do you have problems when people use your menu with no workbook open ?



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"LuisE" <(E-Mail Removed)> wrote in message news80408C1-F8AC-4BAE-AD07-(E-Mail Removed)...
> Thanks Ron, merry Christmas by the way.
>
> Yes I did.
> My concern is that the Add-In will remain installed even if not workbook in
> opened so I'd imagine that it is technically not closed, is it?
>
>
>
> "Ron de Bruin" wrote:
>
>> Do you create the menu with VBA code ?
>>
>> You can create the menu in the Open even and close it in the beforeclose event
>> See this example
>>
>> Debra Dalgleish's (Toolbar example from Dave Peterson)
>> http://www.contextures.com/xlToolbar02.html
>>
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.nl/tips.htm
>>
>>
>> "LuisE" <(E-Mail Removed)> wrote in message news:9AE031B5-1918-423E-9A5A-(E-Mail Removed)...
>> >I have a menu from an Add-In, when all workbooks are closed and all the other
>> > menus are disabled mine remains enabled.
>> > How can I disabled it so if someone clicks it no error message is generated?
>> > Just as the built-in ones.
>> >
>> > Thanks in advance
>> >

>>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      26th Dec 2007
You can add this to your macro if you not want to run the code if there is no
workbook open.
If there are a lot of macros you can also build a function to do the test so you only
have to add one code line to each macro.

On Error GoTo QuitOpen
ActiveWorkbook.Activate
'Your macro code
Exit Sub
QuitOpen:
MsgBox "There is no file open", , "YourProgName"
Exit Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ron de Bruin" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>A add-in will close when you close Excel.
>
> Can you explain more what you want ?
> Do you have problems when people use your menu with no workbook open ?
>
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "LuisE" <(E-Mail Removed)> wrote in message news80408C1-F8AC-4BAE-AD07-(E-Mail Removed)...
>> Thanks Ron, merry Christmas by the way.
>>
>> Yes I did.
>> My concern is that the Add-In will remain installed even if not workbook in
>> opened so I'd imagine that it is technically not closed, is it?
>>
>>
>>
>> "Ron de Bruin" wrote:
>>
>>> Do you create the menu with VBA code ?
>>>
>>> You can create the menu in the Open even and close it in the beforeclose event
>>> See this example
>>>
>>> Debra Dalgleish's (Toolbar example from Dave Peterson)
>>> http://www.contextures.com/xlToolbar02.html
>>>
>>>
>>> --
>>>
>>> Regards Ron de Bruin
>>> http://www.rondebruin.nl/tips.htm
>>>
>>>
>>> "LuisE" <(E-Mail Removed)> wrote in message news:9AE031B5-1918-423E-9A5A-(E-Mail Removed)...
>>> >I have a menu from an Add-In, when all workbooks are closed and all the other
>>> > menus are disabled mine remains enabled.
>>> > How can I disabled it so if someone clicks it no error message is generated?
>>> > Just as the built-in ones.
>>> >
>>> > Thanks in advance
>>> >
>>>

 
Reply With Quote
 
LuisE
Guest
Posts: n/a
 
      27th Dec 2007
It works fine, thank you ron

"Ron de Bruin" wrote:

> You can add this to your macro if you not want to run the code if there is no
> workbook open.
> If there are a lot of macros you can also build a function to do the test so you only
> have to add one code line to each macro.
>
> On Error GoTo QuitOpen
> ActiveWorkbook.Activate
> 'Your macro code
> Exit Sub
> QuitOpen:
> MsgBox "There is no file open", , "YourProgName"
> Exit Sub
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.nl/tips.htm
>
>
> "Ron de Bruin" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >A add-in will close when you close Excel.
> >
> > Can you explain more what you want ?
> > Do you have problems when people use your menu with no workbook open ?
> >
> >
> >
> > --
> >
> > Regards Ron de Bruin
> > http://www.rondebruin.nl/tips.htm
> >
> >
> > "LuisE" <(E-Mail Removed)> wrote in message news80408C1-F8AC-4BAE-AD07-(E-Mail Removed)...
> >> Thanks Ron, merry Christmas by the way.
> >>
> >> Yes I did.
> >> My concern is that the Add-In will remain installed even if not workbook in
> >> opened so I'd imagine that it is technically not closed, is it?
> >>
> >>
> >>
> >> "Ron de Bruin" wrote:
> >>
> >>> Do you create the menu with VBA code ?
> >>>
> >>> You can create the menu in the Open even and close it in the beforeclose event
> >>> See this example
> >>>
> >>> Debra Dalgleish's (Toolbar example from Dave Peterson)
> >>> http://www.contextures.com/xlToolbar02.html
> >>>
> >>>
> >>> --
> >>>
> >>> Regards Ron de Bruin
> >>> http://www.rondebruin.nl/tips.htm
> >>>
> >>>
> >>> "LuisE" <(E-Mail Removed)> wrote in message news:9AE031B5-1918-423E-9A5A-(E-Mail Removed)...
> >>> >I have a menu from an Add-In, when all workbooks are closed and all the other
> >>> > menus are disabled mine remains enabled.
> >>> > How can I disabled it so if someone clicks it no error message is generated?
> >>> > Just as the built-in ones.
> >>> >
> >>> > Thanks in advance
> >>> >
> >>>

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable/Disable Commandbar buttons =?Utf-8?B?Qm9kbw==?= Microsoft Outlook Program Addins 3 12th Jul 2007 02:14 PM
Commandbar menu, worksheet modules and workbook module. Dave Microsoft Excel Programming 2 30th Jan 2007 07:30 PM
Disable menu item when a particular excel file is opened Dileep Chandran Microsoft Excel Programming 2 21st Dec 2006 04:55 AM
Saving CommandBar with Workbook pjd Microsoft Excel Worksheet Functions 0 12th Jul 2004 09:44 AM
Disable Save As just for opened workbook Daniel Wright Microsoft Excel Programming 0 25th Jul 2003 09:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:46 AM.