Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically starting Macros

Status
Not open for further replies.

ColmR

Technical User
Aug 25, 2004
12
IE
Hi all,

I am presently running macros that take aproximately 20 minutes to run, which ties up my PC time every morning. I would like to run these macros during the night so that are completed for the following morning. I can setup my PC to open the file which contains the macros at a specified time but I cannot get the macros to run automatically once the file is open.

Any help with this will be greatly appreciated.

Regards,
ColmR
 
Hi ColmR,

Word and Excel are very slightly different, but both have the capacity to run macros when a document or workbook is opened (or indeed, when the application is started although that is a slightly more complicated setup).

You can create AutoMAcros just by giving them the appropriate name (AutoOpen, AutoNew, etc) or there are Document_Open and Workbook_Open Events). Depending exactly what you want there is also a /m switch to run a macro on opening, which might fit the bill.

What type of file are you opening, and how?



Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Hi Tony,

Thank you for your quick reply.
I am currently opening a file in excel("Production Monitoring") manually and then running 2 different macros which copy info from a number of other files.
Ideally I would like to have a seperate file automatically which would in turn open the "Production Monitoring" file and run both macros (one after the other) This will allow me to open the "Production Monitoring" file normally and not have to worry about the macros running every time I open the file.

Would you suggest joining both macros together instead of trying to run both 1 after the other?

Regards,
ColmR
 
ColmR,

There shouldn't be any problem running two consecutive macros. You could use a macro to open the target file then call the other two macros, or just open the file at the beginning of the first macro.

As far as having a macro run overnight goes, I've used the following method successfully for a while now. It will require you to keep a workbook open overnight, but, as I said, it works quite well.

Details can be found here or here. If you have any questions about it, just post back here.

The links should pretty much walk you right through setting up a macro that will run at a predefined time.



[tt]__________________________________________
My name is John, and I approved this post.[/tt]

To get the best answers fast, please read faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top