Default excel Template

S

shivakumar

Hi,


Can a macro be set to the default excel template so that
when ever a user opens a new spreadsheet the macro is
executed?

where can the default excel template located?

thanks,
Shiv
..
 
C

Chris Nicholas

Shiv,

There is no way to truly create a Default template for Excel like you can
with Word. However, if you have a desire to run a specific set of code with
each file being opened you can capture the Workbook Open event in your own
class module of the personal.xls.

Create a Module in Personal.xls and add the following code:

Dim AppObject as New Class1

Sub Auto_Open
Set AppObject.AppEvent = Application
End Sub

Create a New Class Module in Personal.xls and add the following code.

Public WB as Workbook
Public WithEvents AppEvent as Application

Private Sub AppEvent_WorkbookOpen(ByVal WB as Excel.Workbook)
'Enter the code you want to run each time a workbook is opened
Debug.Print WB.Name
End Sub

Now if you are just looking for something that will look like the default
template such as Book1. You can create your own book.xlt and put it in the
XLStart folder and each time Excel is launched it will open this book up.
If you have a Open event or Auto_Open in this template it will run each time
the workbook is opened, even after saving it to the new name.
 

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

Top