Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default How to call a workbook Event..

Hi,
I would like to know how to initiate a workbook event from a
subroutine. It seems like it should be something like Call
Workbook_Open
Thanks,
Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to call a workbook Event..

There are two general approaches:

1. Use the Context
Say the workbook code is:

Private Sub Workbook_NewSheet(ByVal Sh As Object)
MsgBox ("sheet added")
End Sub

and we want this executed by another macro. Just make the macro add a sheet:

Sub newsheet()
Sheets.Add
End Sub

and the Event gets triggered.


2. Without Context

Here we want the code executed, but without actually adding a sheet. Here
make the workbook code:

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Call sheetsettup
End Sub

where sheetsettup is a macro in a standard module. Now any other macro can
also call sheetsettup.
--
Gary''s Student - gsnu200784


"Matt" wrote:

Hi,
I would like to know how to initiate a workbook event from a
subroutine. It seems like it should be something like Call
Workbook_Open
Thanks,
Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default How to call a workbook Event..

Almost. It would be

Call ThisWorkbook.Workbook_Open

but you must make Workbook_Open a Public procedure, the default signature is
private.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Matt" wrote in message
...
Hi,
I would like to know how to initiate a workbook event from a
subroutine. It seems like it should be something like Call
Workbook_Open
Thanks,
Matt



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
Call Event as Sub Clayman Excel Programming 2 August 7th 07 03:40 PM
how to call the event of other worksheet chad Excel Worksheet Functions 1 May 30th 07 09:48 AM
How to call an event procedure Ben Excel Programming 2 December 6th 05 05:40 PM
Event to call before a opened workbook is recalculated Torben Laursen[_2_] Excel Programming 4 December 16th 04 05:32 PM
how to call a macro from a worksheet event? lopsided[_3_] Excel Programming 5 December 16th 03 10:28 AM


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