ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autorun a macro (https://www.excelbanter.com/excel-programming/339274-autorun-macro.html)

Paul Wisken

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


Andy

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



Paul Wisken

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 ***

Snake Plissken[_2_]

Autorun a macro
 
section "thisworkbook" in vba manager and then:

Private Sub Workbook_Open()

End Sub

[email protected]

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


dominicb[_114_]

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


Whiskers

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