PC Review


Reply
Thread Tools Rate Thread

How to call a workbook Event..

 
 
Matt
Guest
Posts: n/a
 
      7th May 2008
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 With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      7th May 2008
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
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      7th May 2008
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" <(E-Mail Removed)> wrote in message
news:b13b5750-e69f-4313-aeb1-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I call up a line of code that references a cell/range in theactive workbook workbook where I am running my macro from? Lav Microsoft Excel Programming 1 11th Nov 2008 05:04 PM
How do I call number values form one workbook to another workbook Teryn Microsoft Excel Worksheet Functions 3 29th Dec 2007 09:21 AM
Call javascript function without using any event call cschang Microsoft ADO .NET 3 1st Feb 2005 03:04 AM
Call function from one workbook that resides in another workbook m =?Utf-8?B?RGF0YXNvcnQ=?= Microsoft Excel Programming 3 16th Jan 2005 10:33 PM
Event to call before a opened workbook is recalculated Torben Laursen Microsoft Excel Programming 4 16th Dec 2004 05:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:11 PM.