Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default enabling a custom menu at workbook open that is disabled

In an add-in I have created, a custom menu item is created, it is
disabled at the end of the macro that created it with:

CommandBars(1).Controls("blah blah").Enabled = False

I did this because not all workbooks should be able to use it. The
menu is created and greyed out when Excel is started.

In the workbook_open macro of theworkbooks I want the menu to be
available, I placed:

CommandBars(1).Controls("blah blah").Enabled = True

to turn it back on. When the workbook opens, I get:

"Object variable or with block not set"

I haven't been able to figure it out. Any help would be appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default enabling a custom menu at workbook open that is disabled

Take your code out of Workbook_Open and put it in a procedure
called Auto_Open in a regular code module, not the ThisWorkbook
module. Sometimes, Excel hasn't fully put itself together when
Workbook_Open runs.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
oups.com...
In an add-in I have created, a custom menu item is created, it
is
disabled at the end of the macro that created it with:

CommandBars(1).Controls("blah blah").Enabled = False

I did this because not all workbooks should be able to use it.
The
menu is created and greyed out when Excel is started.

In the workbook_open macro of theworkbooks I want the menu to
be
available, I placed:

CommandBars(1).Controls("blah blah").Enabled = True

to turn it back on. When the workbook opens, I get:

"Object variable or with block not set"

I haven't been able to figure it out. Any help would be
appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default enabling a custom menu at workbook open that is disabled

I should have added that you should use the command bar name
rather than number. E.g.,

CommandBars("Worksheet Menu Bar").Controls("blah blah").Enabled =
True

Using the number seems unpredicable. For example,
Debug.Print CommandBars(1).Name
displays "WordArt" for me.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Chip Pearson" wrote in message
...
Take your code out of Workbook_Open and put it in a procedure
called Auto_Open in a regular code module, not the ThisWorkbook
module. Sometimes, Excel hasn't fully put itself together when
Workbook_Open runs.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
oups.com...
In an add-in I have created, a custom menu item is created, it
is
disabled at the end of the macro that created it with:

CommandBars(1).Controls("blah blah").Enabled = False

I did this because not all workbooks should be able to use it.
The
menu is created and greyed out when Excel is started.

In the workbook_open macro of theworkbooks I want the menu to
be
available, I placed:

CommandBars(1).Controls("blah blah").Enabled = True

to turn it back on. When the workbook opens, I get:

"Object variable or with block not set"

I haven't been able to figure it out. Any help would be
appreciated.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default enabling a custom menu at workbook open that is disabled

Thanks, that did the trick. I was hoping to avoid the enable macros
dialog, but I can live with it.


Chip Pearson wrote:
Take your code out of Workbook_Open and put it in a procedure
called Auto_Open in a regular code module, not the ThisWorkbook
module. Sometimes, Excel hasn't fully put itself together when
Workbook_Open runs.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC


Reply
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
custom menu cross contamination between open workbooks. windsurferLA Excel Programming 2 May 12th 05 06:03 PM
How: open a workbook with auto macro disabled using code? mike_cutting-edge Excel Programming 1 February 13th 05 06:29 PM
Excel crashes when attempting to open workbook...even with macros disabled llowwelll[_10_] Excel Programming 1 May 24th 04 09:38 PM
Custom Menu Item specific to a workbook Tommy T Excel Programming 1 January 23rd 04 07:34 PM
Autoload custom menu on Workbook Open Johann[_2_] Excel Programming 1 December 30th 03 07:55 AM


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

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

About Us

"It's about Microsoft Excel"