LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Conditionally enable/disable a custom menu

I have a menu added to the main menu bar which I would like to disable if an
active workbook doesn't meet certain criteria. I have a couple of questions.
Currently I'm testing this as a .xls, but I will be converting to a .xla.

Here's what I tried

1 Private Sub Workbook_WindowActivate(ByVal Wn As Window)
2 If Range("A1").Value = "AgentName" And Range("A2").Value = "AvailTime" Then
3 CommandBars(1).Controls("CDR Stats").Enabled = True
4 Else
5 CommandBars(1).Controls("CDR Stats").Enabled = False
6 End If
7 End Sub

It seems to be evaluating when I switch to the workbook the code is held in.
It is hanging up on line 5 and I am receiving Run-time error '91': Object
variable or With block variable not set

Question 1: What am I doing wrong in my code?

Question 2: Once I convert this to a .xla I want this to check every time
the user switches workbooks. Is this the correct Event procedure? I'm
guessing I need something different.

Thanks in advance for helping out a newbie.




 
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
Disable custom menu item based on visible cells stewart Excel Programming 1 January 1st 08 05:46 PM
Context Menu (Sub-Menu Disable/Enable) JR_06062005[_2_] Excel Programming 4 August 31st 06 06:01 PM
Disable custom drop-down menu Piers 2k Excel Programming 1 August 16th 06 09:46 AM
Enable/Disable Menu Items Andrew Kennard Excel Programming 3 January 25th 05 04:12 PM
Menu Items and Disable/Enable in Excel 2003 [email protected] Excel Programming 1 February 6th 04 08:14 PM


All times are GMT +1. The time now is 08:17 AM.

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"