View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JulieD JulieD is offline
external usenet poster
 
Posts: 618
Default 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