Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically executing a subroutine/macro when opening a file

Status
Not open for further replies.

rendezvous

IS-IT--Management
Feb 27, 2003
5
CA
How do you get an excel file to automatically launch a macro as soon as the file is opened?

thanks
 
[tt]Here are two example macros that will run as soon as excel opens:

This macro opens the workbook at sheet 1 even if you save it at page 100
1.
Option Explicit
Private Sub Workbook_Open()
Worksheets("Sheet1").Select
Application.Goto Reference:="Cell Location"
End Sub


This macro opens your document at 80% it's size
2.
Private Sub Workbook_Open()
ActiveWindow.Zoom = 80
End Sub


T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
Progress2.gif

 
You can't put these subs just anywhere - they belong in the code for the workbook object. Double-click on the workbook name in the VBE project explorer (top left of VBE screen) to get to that code module, and then create your workbook_open sub there.
Rob
[flowerface]
 
Oops, forgot to mention that.... Thanks


flowerface.gif

T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
Progress2.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top