S
Stephen Lloyd
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.
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.