ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autorun Macro on file opening (https://www.excelbanter.com/excel-programming/314706-autorun-macro-file-opening.html)

Sha-auto

Autorun Macro on file opening
 

Hi,
I need to run a Macro automatically, when I open a file - is thi
possible ? If so could you let me know how, or steer me in the righ
direction at least. I couldn't find it in Excel help or on this foru
as a question posted previously.
I want to open a file from a desktop shortcut and then run the Macr
automatically...
Many thanks to all you Excel wizards out there, I found some ver
interesting ideas/solutions when hunting for this answer

--
Sha-aut
-----------------------------------------------------------------------
Sha-auto's Profile: http://www.excelforum.com/member.php...fo&userid=1570
View this thread: http://www.excelforum.com/showthread.php?threadid=27233


Myrna Larson

Autorun Macro on file opening
 
Put your code in the Workbook_Open event, in the ThisWorkbook module that you
see in the project pane in the VB Editor.

On Mon, 25 Oct 2004 21:31:29 -0500, Sha-auto
wrote:


Hi,
I need to run a Macro automatically, when I open a file - is this
possible ? If so could you let me know how, or steer me in the right
direction at least. I couldn't find it in Excel help or on this forum
as a question posted previously.
I want to open a file from a desktop shortcut and then run the Macro
automatically...
Many thanks to all you Excel wizards out there, I found some very
interesting ideas/solutions when hunting for this answer.



eRiC

Autorun Macro on file opening
 
Private Sub Workbook_Open()
'Type the first procedure or function call here
End Sub



JulieD

Autorun Macro on file opening
 
Hi Sha-auto

here's a reply i sent to a friend the other day with the same question:
to run a macro automatically when a workbook opens use the WORKBOOK_OPEN
procedure - in the "THISWORKBOOK" module and not stored in a normal macro
sheet - to get there ..
1) right mouse click on a sheet tab in your excel workbook and choose view
code
2) in the VBE window you should see your workbook's name in bold (& in
brackets) on the top left, if not, choose view / project explorer -
underneath the workbook's name you should see Sheet1, Sheet2, Sheet3 etc and
ThisWorkbook.
3) double click on ThisWorkbook
4) on the right hand side of the screen choose from the left hand drop down
"Workbook" and from the right hand one "Open" if it doesn't appear
automatically
5) now put your code in here between the Private Sub Workbook_Open()
and the
End Sub
6) close the VBE window using the X top right hand side.

oh, and you also need to set your security (tools / macro / security)
settings to medium or low (not recommended) for the macro to work when you
open the workbook


Hope this helps
Cheers
JulieD


"Sha-auto" wrote in message
...

Hi,
I need to run a Macro automatically, when I open a file - is this
possible ? If so could you let me know how, or steer me in the right
direction at least. I couldn't find it in Excel help or on this forum
as a question posted previously.
I want to open a file from a desktop shortcut and then run the Macro
automatically...
Many thanks to all you Excel wizards out there, I found some very
interesting ideas/solutions when hunting for this answer.


--
Sha-auto
------------------------------------------------------------------------
Sha-auto's Profile:
http://www.excelforum.com/member.php...o&userid=15704
View this thread: http://www.excelforum.com/showthread...hreadid=272332





All times are GMT +1. The time now is 07:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com