Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Private Sub Workbook_Open() doesn't run | Excel Discussion (Misc queries) | |||
Failure to execute Private Workbook_Open | Excel Programming | |||
XL97 Private Sub Workbook_Open() Not Working | Excel Programming | |||
Cannot get Auto_Open or Private Sub Workbook_Open() to run at star | Excel Programming | |||
Private Sub Workbook_Open() not running on open | Excel Programming |