![]() |
startup macro on condition of filename
Please suggest how to use the startup macro when the filename was open
eg.: when I open report.xls the macro should be autorun but the other files was open the macro notrun thanks, |
startup macro on condition of filename
arun,
I'm a little confused from your post. To run a macro when a workbook opens, you can name the sub Auto_Open Sub Auto_Open() ' your code End Sub The above will automatically run whenever the workbook that it's contained within is opened. If you're looking to run a particular macro when the workbook is opened from another workbook only, use the Application.Run function from the original workbook. Workbooks.Open Filename:="FileName.xls" Application.Run "'FileName.xls'!MacroName" John "arun" wrote in message ... Please suggest how to use the startup macro when the filename was open ? eg.: when I open report.xls the macro should be autorun but the other files was open the macro notrun. thanks, |
startup macro on condition of filename
I just got done doing this.. I created a class event inside a addin and then
followed Chip Pearson's advice: You need to use application events to trap for workbook being opened. See www.cpearson.com/excel/appevent.htm for more details. I altered the workbook_open event to continue to execute if the wb.name was correct. I found out later I coded it case-sensitive. "arun" wrote in message ... Please suggest how to use the startup macro when the filename was open ? eg.: when I open report.xls the macro should be autorun but the other files was open the macro notrun. thanks, |
All times are GMT +1. The time now is 01:05 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com