Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to register an event handler when excel opens

Folks,

I have written an event handler to to validate the work book name before
saving a work book. Ineed to know what code do I have to write to have the
event handler register itself when Excel starts.

Also is there some install procedure where I can move my code and user
from into the personal.xls in the XLSStart directory? I can do it by hand
but that is a pain.

Thanks,

{John}

I miss Cusp and Mesa.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to register an event handler when excel opens

See Chip Pearson's page on Application Level events

http://www.cpearson.com/excel/appevent.htm

for writing code with code
http://www.cpearson.com/excel/vbe.htm

--
Regards,
Tom Ogilvy


"John Davidson" wrote in message
...
Folks,

I have written an event handler to to validate the work book name before
saving a work book. Ineed to know what code do I have to write to have

the
event handler register itself when Excel starts.

Also is there some install procedure where I can move my code and user
from into the personal.xls in the XLSStart directory? I can do it by hand
but that is a pain.

Thanks,

{John}

I miss Cusp and Mesa.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default How to register an event handler when excel opens

John,

you'll need to setup a classmodule to hook into
excel's application object.from there you can monitor all events
within the running instance of excel.

Here's how:

in your app:

insert a new classmodule
rename it to :clsAppEvent


'code for clsAppEvent
Option Explicit
Dim WithEvents xlApp As Application
Private Sub Class_Initialize()
Set xlApp = Application
End Sub
Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
MsgBox "you opened " & Wb.Name
End Sub


'code for ThisWorkbook
Option Explicit
Dim appMon As clsAppEvent
Private Sub Workbook_Open()
Set appMon = New clsAppEvent
End Sub

as long as there's no stateloss.. everytime a workbook is opened
you'll get a message.

Hopefully this is illustrative of the technique,
now you can search & find lots of other examples.




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"John Davidson" wrote:

Folks,

I have written an event handler to to validate the work book name
before
saving a work book. Ineed to know what code do I have to write to
have the event handler register itself when Excel starts.

Also is there some install procedure where I can move my code and
user
from into the personal.xls in the XLSStart directory? I can do it by
hand but that is a pain.

Thanks,

{John}

I miss Cusp and Mesa.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to register an event handler when excel opens

I have code to register my class module what I need to do is cause this
code to execute when Excel starts up sort of like a autoexec.

{John}

"Tom Ogilvy" wrote in message
...
See Chip Pearson's page on Application Level events

http://www.cpearson.com/excel/appevent.htm

for writing code with code
http://www.cpearson.com/excel/vbe.htm

--
Regards,
Tom Ogilvy


"John Davidson" wrote in message
...
Folks,

I have written an event handler to to validate the work book name

before
saving a work book. Ineed to know what code do I have to write to have

the
event handler register itself when Excel starts.

Also is there some install procedure where I can move my code and

user
from into the personal.xls in the XLSStart directory? I can do it by

hand
but that is a pain.

Thanks,

{John}

I miss Cusp and Mesa.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to register an event handler when excel opens

Code would have to be in a workbook that is opened when Excel opens.
Choices would be

Personal.xls
an addin that will be loaded
Other workbook in the xlstart directory.

Then the workbook_Open event would have to trigger the code you have
written.

If Excel is opened programmatically via automation, non of these files would
be loaded by default.

To establish this environment, you would need the user to run some type of
install routine.

--
Regards,
Tom Ogilvy


"John Davidson" wrote in message
...
I have code to register my class module what I need to do is cause this
code to execute when Excel starts up sort of like a autoexec.

{John}

"Tom Ogilvy" wrote in message
...
See Chip Pearson's page on Application Level events

http://www.cpearson.com/excel/appevent.htm

for writing code with code
http://www.cpearson.com/excel/vbe.htm

--
Regards,
Tom Ogilvy


"John Davidson" wrote in message
...
Folks,

I have written an event handler to to validate the work book name

before
saving a work book. Ineed to know what code do I have to write to

have
the
event handler register itself when Excel starts.

Also is there some install procedure where I can move my code and

user
from into the personal.xls in the XLSStart directory? I can do it by

hand
but that is a pain.

Thanks,

{John}

I miss Cusp and Mesa.








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
where is the workbook_open event handler??? Steff_DK[_10_] Excel Programming 2 April 25th 04 02:43 PM
different IDispatch in event handler Dirk[_2_] Excel Programming 0 January 23rd 04 11:04 PM
Cell Event Handler David Excel Programming 3 January 19th 04 04:51 PM
Re : Excel event handler Worksheet_SelectionChange TKT-Tang Excel Programming 1 July 18th 03 08:27 AM
Re : Excel event handler Worksheet_SelectionChange TKT-Tang Excel Programming 1 July 16th 03 07:21 AM


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