Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default 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,



  #3   Report Post  
Posted to microsoft.public.excel.programming
Yo Yo is offline
external usenet poster
 
Posts: 11
Default 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,



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
Startup Macro Max Excel Discussion (Misc queries) 6 May 24th 07 01:20 PM
starting a macro at startup chip_pyp Excel Discussion (Misc queries) 1 March 22nd 06 06:59 PM
Startup macro Zeno Excel Discussion (Misc queries) 1 June 29th 05 01:06 PM
Workbook startup condition wikegolfa Excel Discussion (Misc queries) 3 December 16th 04 03:11 PM
Run a macro at startup Robyn Thomas Excel Programming 1 January 10th 04 09:44 PM


All times are GMT +1. The time now is 12:25 PM.

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"