ict-torquilclark
asked on
Run VBA conditionally on file name
Is there a way to have a macro automatically run if it has a certain file name?
ASKER
I am unsure weather this will achive what I need it to. The probalem is that every night the spreadsheet in question is overwritten with ther new one. Because the spreadsheet is overwritten does this mean that thre code will not work?
Thanks
Thanks
If the spreadsheet in question is overwritten by another spreadsheet that does not contain the code, then there will then be no code to execute. Please could you explain in detail what it is you want to achieve.
ASKER
I have some statistics software that creates a .xls file every morning at 1:00am. The filepath and filename are always the same each time the file is created (and so the previous spreadsheet is overwritten). I have created a schedualed task to open the spreadhseet at 1:30 am. I have also created some code in the personal maco workbook so it is available each time a new spreadsheet is created to format the data and then email it to the required people. What I need to do is for excel to check the spreadsheet upon it opening and run the code (from the personal macro workbook) if the filename is "stats.xls".
I hape that makes sense.
Please ask if you have any more questions.
I hape that makes sense.
Please ask if you have any more questions.
Is the computer unattended ie you want the file opening and checking to happen automatically with no user involvement? Is it Windows Task Scheduler you're using to open the specific file?
ASKER
The comnputer is unattended. I want to make the process compleatly automated. Windows is using Schedualed tasks (start > all programs > accessories > system tools > schedualed tasks) to open the file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That's a simple and neat solution Rorya :-)
Thank you very much RichardSchollar! :)
(why are we being so formal??)
(why are we being so formal??)
Do I know you? ;-)
That 'a' on the end was a typo! No idea how I managed that...
That 'a' on the end was a typo! No idea how I managed that...
Richard
Open in new window