Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Application level events - calling from standard module

I need to call an application event from a standard module, the
difference here is that it needs to be called each time a new workbook
is opened.

This has been developed as an addin so that any user can install the
application with little or no effort.

Initially the code was located in the standard module and any automatic
procedures called from ThisWorkbook's Workbook_open event. The code
basically builds a custom menu, amongst other things, which checks
certain conditions within a workbook and then disables part of the
custom menu should these conditions be true.

I need this code to be run whenever a workbook is opened, hence
application level events - my problem is that workbook_open events are
not available on the standard module as far as I know.

Am I going about this the right way or are there any alternatives?

I hope this is clear.

Thanks in advance

T.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Application level events - calling from standard module

This is just a shade trickier than you probably first imagined it would be.
You need to instantiate a class to catch the events... Create a class module
and Name it clsXLEvents. In it place the following code...

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub Class_Initialize()
Set xlApp = Excel.Application
End Sub

Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
MsgBox "Tada"
End Sub

Now in a standard module add the following code

Dim objXLEvents As clsXLEvents

Public Sub Auto_Open()
Set objXLEvents = New clsXLEvents
End Sub

This should do it for you...

--
HTH...

Jim Thomlinson


"triaz" wrote:

I need to call an application event from a standard module, the
difference here is that it needs to be called each time a new workbook
is opened.

This has been developed as an addin so that any user can install the
application with little or no effort.

Initially the code was located in the standard module and any automatic
procedures called from ThisWorkbook's Workbook_open event. The code
basically builds a custom menu, amongst other things, which checks
certain conditions within a workbook and then disables part of the
custom menu should these conditions be true.

I need this code to be run whenever a workbook is opened, hence
application level events - my problem is that workbook_open events are
not available on the standard module as far as I know.

Am I going about this the right way or are there any alternatives?

I hope this is clear.

Thanks in advance

T.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Application level events - calling from standard module

Thanks Jim, you're a diamond. One very slight, not really that
important, issue. It does not seem to work when opening a blank / new
workbook?

Thank you.

T.

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
Calling worksheet module from other module. Michael Malinsky Excel Programming 2 December 14th 05 08:47 PM
Application level events John Excel Programming 1 November 25th 05 07:22 PM
Code: Using Excel Application level Events Chris W[_3_] Excel Programming 0 February 27th 05 07:40 PM
Application Level Events Question nickg420[_4_] Excel Programming 3 July 16th 04 05:02 PM
Application level events no longer execute R Avery Excel Programming 1 June 4th 04 01:21 AM


All times are GMT +1. The time now is 05:31 AM.

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

About Us

"It's about Microsoft Excel"