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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

start Excel macro automatically

Status
Not open for further replies.

sunnywink

Technical User
Oct 6, 2002
49
FR
Hi all,

I constructed an excel file recently with macro properties. Does anyone know how to enable the macro to run automatically whenever the file the opened?

Many thanks in advance.
 
You need to call the macro from the workbook's Open() event:

Code:
'@---------- Workbook Module ------------@

Private Sub Workbook_Open()
  Call GetFileName
End Sub



'@-------------- Module 1 ---------------@

'Macros

Sub GetFileName()
  Dim strTitle As String
  
  strTitle = InputBox("Enter Workbook Name:", "Title", "")
  
  If Len(strTitle) > 0 Then
    ActiveWorkbook.SaveAs strTitle & ".xls"
  End If
End Sub
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top