Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Code for App level event (not firing)

This is the code im my class module called:
EventClassModule

Public WithEvents App As Application

Private Sub App_WorkbookDeactivate(ByVal Wb As Workbook)
Dim cnt As Integer, X As Integer
If ActiveWorkbook Is Nothing Then
cnt = Application.CommandBars("Worksheet Menu
Bar").Controls.Count
For X = 1 To cnt
If Application.CommandBars("Worksheet Menu
Bar").Controls(X).Caption = "&Rolodex Tools" Or _
Application.CommandBars("Worksheet Menu
Bar").Controls(X).Caption = "&Rolodex Tools*" Then
Application.CommandBars("Worksheet Menu
Bar").Controls(X).Enabled = False
Exit Sub
End If
Next X
End If
End Sub
--------------------------------------------------------

This is the subroutine placed in a standard module (this
is called from the ThisWorkbook Workbook_Open() event of
Personal.XLS.

Dim EvntCl As New EventClassModule

Sub InitializeApp()
Set EvntCl.App = Application
End Sub
----------------------------------------------------------

-----Original Message-----
It would be useful if you posted the code you are using.


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



"Chris w." wrote in

message
...
Excel level Event not firing. I followed the directions
given in Excel Help to initialize the App level events.
But the event is not firing. I created a class object

for
the Application object. I put an initialize subroutine
code in a workbook level module, and I call it in the
openworkbok event. All of these are in Personal.xls.

Can
someone give me assistance. Is there a scope problem?
Please help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Code for App level event (not firing)

Try putting the Set command in the ThisWorkbook Workbook_Open() event of
Personal.XLS.

Private Sub Workbook_Open()
Set EvntCl.App = Application

HTH,
Gary Brown


"Chris W" wrote in message
...
This is the code im my class module called:
EventClassModule

Public WithEvents App As Application

Private Sub App_WorkbookDeactivate(ByVal Wb As Workbook)
Dim cnt As Integer, X As Integer
If ActiveWorkbook Is Nothing Then
cnt = Application.CommandBars("Worksheet Menu
Bar").Controls.Count
For X = 1 To cnt
If Application.CommandBars("Worksheet Menu
Bar").Controls(X).Caption = "&Rolodex Tools" Or _
Application.CommandBars("Worksheet Menu
Bar").Controls(X).Caption = "&Rolodex Tools*" Then
Application.CommandBars("Worksheet Menu
Bar").Controls(X).Enabled = False
Exit Sub
End If
Next X
End If
End Sub
--------------------------------------------------------

This is the subroutine placed in a standard module (this
is called from the ThisWorkbook Workbook_Open() event of
Personal.XLS.

Dim EvntCl As New EventClassModule

Sub InitializeApp()
Set EvntCl.App = Application
End Sub
----------------------------------------------------------

-----Original Message-----
It would be useful if you posted the code you are using.


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



"Chris w." wrote in

message
...
Excel level Event not firing. I followed the directions
given in Excel Help to initialize the App level events.
But the event is not firing. I created a class object

for
the Application object. I put an initialize subroutine
code in a workbook level module, and I call it in the
openworkbok event. All of these are in Personal.xls.

Can
someone give me assistance. Is there a scope problem?
Please help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Code for App level event (not firing)

How do you conclude that it is not firing?

Have you considered inserting an unconditional 'MsgBox' statement in
App_WorkbookDeactivate to see if the code executes?

Also, what is "Rolodex Tools*" supposed to be? If it meant to be a
wild card search, VBA's If statement doesn't support that capability.

Finally, instead of looping through all the controls, consider the
direct approach:
commandbars("worksheet menu bar").Controls("Rolodex Tools").enabled= _
not activeworkbook is nothing
--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
This is the code im my class module called:
EventClassModule

Public WithEvents App As Application

Private Sub App_WorkbookDeactivate(ByVal Wb As Workbook)
Dim cnt As Integer, X As Integer
If ActiveWorkbook Is Nothing Then
cnt = Application.CommandBars("Worksheet Menu
Bar").Controls.Count
For X = 1 To cnt
If Application.CommandBars("Worksheet Menu
Bar").Controls(X).Caption = "&Rolodex Tools" Or _
Application.CommandBars("Worksheet Menu
Bar").Controls(X).Caption = "&Rolodex Tools*" Then
Application.CommandBars("Worksheet Menu
Bar").Controls(X).Enabled = False
Exit Sub
End If
Next X
End If
End Sub
--------------------------------------------------------

This is the subroutine placed in a standard module (this
is called from the ThisWorkbook Workbook_Open() event of
Personal.XLS.

Dim EvntCl As New EventClassModule

Sub InitializeApp()
Set EvntCl.App = Application
End Sub
----------------------------------------------------------

-----Original Message-----
It would be useful if you posted the code you are using.


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



"Chris w." wrote in

message
...
Excel level Event not firing. I followed the directions
given in Excel Help to initialize the App level events.
But the event is not firing. I created a class object

for
the Application object. I put an initialize subroutine
code in a workbook level module, and I call it in the
openworkbok event. All of these are in Personal.xls.

Can
someone give me assistance. Is there a scope problem?
Please help.


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
Stop Worksheet_SelectionChange event from firing? Ed Excel Programming 13 January 5th 05 12:57 PM
Worksheet change event not firing Wexler Excel Programming 11 October 25th 04 09:45 PM
Workbook open event not firing (both 2000 and XP) Greg Lesnie Excel Programming 2 October 17th 04 10:31 PM
Workbook.Open Event Procedure not firing Gordon Rodman Excel Programming 1 October 17th 03 05:03 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 10:06 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"