View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chris Nicholas Chris Nicholas is offline
external usenet poster
 
Posts: 4
Default Default excel Template

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.
--
Chris Nicholas, MCSE
"A man may fail many times, but he isn't a failure until he begins to blame
someone else."
--Knox Manning


"shivakumar" wrote in message
...
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
.