Autorun Macro on file opening

  • Thread starter Thread starter Sha-auto
  • Start date Start date
S

Sha-auto

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
 
Put your code in the Workbook_Open event, in the ThisWorkbook module that you
see in the project pane in the VB Editor.
 
Private Sub Workbook_Open()
'Type the first procedure or function call here
End Sub
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top