Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Using - Private Sub Workbook_Open()"

Hi All,

Can we use more than once "Private Sub Workbook_Open()" in one workbook. I
am trying to use to such written macros but I am getting error for the second
one. i was wondering is that only once we can use this.

I am new to VB plz help and Thanks in advance.

SS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Using - Private Sub Workbook_Open()"

hi
only one workbook_open can be use that i am aware of.
if you have 2 macros that you want to run at open you can...
combine the 2 into one
or use the call command in the workbook open macro to call the second.

regards
FSt1

"SANDIND" wrote:

Hi All,

Can we use more than once "Private Sub Workbook_Open()" in one workbook. I
am trying to use to such written macros but I am getting error for the second
one. i was wondering is that only once we can use this.

I am new to VB plz help and Thanks in advance.

SS

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Using - Private Sub Workbook_Open()"

Thanks to both of you,

for your quick response, and giving such a valuable suggestion.

Have a great day..

"Chip Pearson" wrote:

You can have only one _Open event procedure in the ThisWorkbook module, and
that event is called only when the workbook containing the code is opened.
It does not trigger when other workbook are opened. If you need to detect
another workbook being opened (either a new workbook or an existing
workbook, you need to use code like the following:

Option Explicit

Private WithEvents App As Excel.Application

Private Sub Workbook_Open()
Set App = Application
End Sub

Private Sub App_NewWorkbook(ByVal Wb As Workbook)
' called when a new workbook is created.
End Sub

Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
' called when an existing workbook is opened.
End Sub

For more info on Application events, see
http://www.cpearson.com/Excel/AppEvent.aspx .


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"SANDIND" wrote in message
...
Hi All,

Can we use more than once "Private Sub Workbook_Open()" in one workbook. I
am trying to use to such written macros but I am getting error for the
second
one. i was wondering is that only once we can use this.

I am new to VB plz help and Thanks in advance.

SS


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
Private Sub Workbook_Open() doesn't run Steve Starr Excel Discussion (Misc queries) 4 April 3rd 11 05:05 AM
Failure to execute Private Workbook_Open Rick Excel Programming 0 June 5th 07 05:10 PM
XL97 Private Sub Workbook_Open() Not Working Pete Excel Programming 6 April 19th 05 08:47 PM
Cannot get Auto_Open or Private Sub Workbook_Open() to run at star Paul Moles Excel Programming 0 October 28th 04 03:53 PM
Private Sub Workbook_Open() not running on open Tim[_39_] Excel Programming 0 August 30th 04 09:11 PM


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