Reputation: 31
What I'm looking for is having the auto_open() function run on every excel file that is created. Is there a way that this can be implemented?
Upvotes: 0
Views: 673
Reputation: 176
?Application.StartupPath
in the immediate window to find your XLSTART
folder. Book.xlt
or something similar. Auto_Open()
event inside that template, then save it as a template in the XLSTART
Folder. Be sure it actually saves in the correct place and overwrites the original template. NOTE: You may have to change the template file type to .xltm
and delete the original .xlt
version since it will have macros in it.Auto_Open()
event should now be in every new file you create. Automatically open a workbook template or worksheet template when you start Excel
Upvotes: 1
Reputation: 34075
You'll need a separate workbook that contains the code you want to run - for example, your Personal Macro workbook. In the Thisworkbook module of that workbook, add this:
Private WithEvents appExcel As Excel.Application
Private Sub Workbook_Open()
Set appExcel = Application
End Sub
Private Sub appExcel_WorkbookOpen(ByVal Wb As Workbook)
Call Macro1
End Sub
where Macro1 is the code you want to run for each workbook.
Upvotes: 1