View Single Post
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I don't read the help that way.

I read it to say that if you have a template named book.xlt stored in XLStart,
it'll use that as the basis for any new workbook--and that any workbook (.xls)
that's in that folder will be opened when xl starts.

And the "at startup, open all files in" I read to say that any workbook that's
in that folder will be opened when xl starts. But it also can be used to as the
template location for File|new.

From the help from xl2003:

Storing default workbook and worksheet templates
If you've created a template named Book.xlt or Sheet.xlt and saved it in the
XLStart folder, Microsoft Excel uses the template to create new default
workbooks (default startup workbook: The new, unsaved workbook that's displayed
when you start Excel. The default startup workbook is displayed only if you
haven't included other workbooks in the XLStart folder.) or to insert new
worksheets. The XLStart folder is usually located at:

C:\Program Files\Microsoft Office\Office11\XLStart

To use template (.xlt) files stored on a network file location, you can specify
that location as the alternate startup folder (alternate startup folder: A
folder in addition to the XLStart folder that contains workbooks or other files
that you want to be opened automatically when you start Excel and templates that
you want to be available when you create new workbooks.).

====
But I don't think it's that important what the help says! (It's been wrong
before.) But you've seen how excel treats templates in those folders. (The
proof of the pudding is in the eating!)

How about an alternative?

First, clean up that "at startup, ..." box (empty that box in the dialog).

Then start a new workbook and put this into a General module in that workbook:

Option Explicit
Sub auto_open()

Dim myTemplateName As String
Dim testStr As String

myTemplateName = "C:\my documents\excel\book1.xlt"

testStr = ""
On Error Resume Next
testStr = Dir(myTemplateName)
On Error GoTo 0

If testStr = "" Then
'not found
MsgBox myTemplateName & " wasn't found"
Beep
Else
Workbooks.Add template:=myTemplateName
End If

ThisWorkbook.Close savechanges:=False

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel and save it into your XLStart folder. Then close and
reopen excel.

(Ps. change the name of the template.)


Heidi wrote:

I would like a template to auto-display when Excel is launched. I placed the
.xlt in the XLSTART folder and modified Excel Options in OptionsGeneral"At
startup, open all files in" option to point to the location of the .xlt.

The .xlt is failing to auto-load when Excel is launched. I am following the
exact instructions of MS Help. Aurgh!!!


--

Dave Peterson