Need Excel macro to run at startup...


Posted by Jimmy DeLuca on June 18, 2001 12:08 PM

I know this should be a very simple question, but how do I get a macro in Excel to load at startup?

I know in Word you name the public sub "AutoOpen" and you're good to go, but I haven't found one for Excel.

Thanks in advance.

Jimmy D

Posted by Russell on June 18, 2001 2:01 PM

If you have a personal.xls workbook, you can do the following:

In the VBA editor, click the + next to the Personal.xls workbook. Then double-click on "This Workbook". Now a new blank window will come up, and there will be 2 drop-downs at the top - one that says "(General)", and one that says "(Declarations)". Change the "(General)" to "Workbook". A blank function will come up named "Private Sub Workbook_Open()" -- type in your code and you're good to go. If you do not have a personal.xls workbook, you can open a blank workbook, do the steps outlined above, and then save this workbook to your XLSTART directory. It will open every time you open Excel (and since it opens, your workbook_open event will fire also).

Hope this helps,

Russell

Posted by Jimmy DeLuca on June 18, 2001 4:19 PM

I plan on sending this by email and I also want to use this macro for only one workbook... I just read that Excel has an Auto_Open procedure similar to Word's AutoOpen, but I can't seem to get it to work.

Any thoughts on that? That would be perfect for what I need, but it isn't running it as the workbook is opened.

Thanks again.

Jimmy D



Posted by Jimmy D on June 18, 2001 4:32 PM

Never mind that last one... your posting just helped me figure out the Workbook_Open procedure which seems like it will work, as long as it gets stored in the workbook and not the workstation.

Thanks for your help Russell!

Jimmy D