![]() |
Autorun a macro
I'm sure I'm missing something obvious, but is there a way to make a
macro/vba program run automatically when the workbook is opened? In my case I have a link to data on a server that refreshes on opening the workbook and then must be manipulated. Currently I have a button to click, but I want to avoid user forgetfulness if possible. Thanks Paul |
Autorun a macro
Hi Paul
If its the same workbook each time you could try putting the following line into the Workbook_Open event procedure of that workbook: Application.Run "MacroName" Hope that helps Andy "Paul Wisken" wrote: I'm sure I'm missing something obvious, but is there a way to make a macro/vba program run automatically when the workbook is opened? In my case I have a link to data on a server that refreshes on opening the workbook and then must be manipulated. Currently I have a button to click, but I want to avoid user forgetfulness if possible. Thanks Paul |
Autorun a macro
Thanks Andy, Sound simple, but most of that went straight over my head, so it's back to the old VB help now to see what you're talking about. Paul *** Sent via Developersdex http://www.developersdex.com *** |
Autorun a macro
section "thisworkbook" in vba manager and then:
Private Sub Workbook_Open() End Sub |
Autorun a macro
in a module ...
Sub Auto_Open your code here End Sub As soon as the workbook is open the code in the Auto_Open sub will run |
Autorun a macro
Good afternoon Paul Wisken Two ways: First call your macro Auto_Open eg: Sub Auto_Open() Second, the above will work but you should really use the even procedures facility. Put the code for your macro in the ThisWorkboo pane within the VBE, rather than the Modules pane and then change th name to Workbook_Open(). Does that make any more sense...? For more information about this have a look he http://www.cpearson.com/excel/events.htm HTH Dominic -- dominic ----------------------------------------------------------------------- dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893 View this thread: http://www.excelforum.com/showthread.php?threadid=43660 |
Autorun a macro
Thanks everyone.
It's now working perfectly Paul *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 10:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com