Worksheets.Add won't let me specify a template
Xl2003 add some words:
Type Optional Variant. Specifies the sheet type. Can be one of the following
XlSheetType constants: xlWorksheet, xlChart, xlExcel4MacroSheet, or
xlExcel4IntlMacroSheet. If you are inserting a sheet based on an existing
template, specify the path to the template. The default value is xlWorksheet.
Maybe in xl2004, they'll add that specifying the user template will only work
with sheets.add (not worksheets.add) <vbg.
(and that "worksheets.add type:=xlChart" won't work, either.)
NickHK wrote:
byundt,
XL2000 Help:
<
Add Method (Worksheets Collection)
Creates a new worksheet. The new worksheet becomes the active sheet. Returns
a Worksheet object.
Syntax
expression.Add(Before, After, Count, Type)
expression Required. An expression that returns a Worksheets object.
............
Type Optional Variant. The sheet type. Can be one of the following
XlSheetType constants: xlWorksheet, xlExcel4MacroSheet, or
xlExcel4IntlMacroSheet. The default value is xlWorksheet.
/
No mention of Template. Only with Workbooks.Add.
Which makes sense really.
NickHK
"byundt" wrote in message
...
In Excel 2003, the documentation for Worksheets.Add suggests that I can
use
the Type parameter to specify a path to a template for an added worksheet.
This works with Sheets.Add, but produces a 1004 run-time error with
Worksheets.Add
Although the workaround is simple, the on-line help ought to be changed.
The following code will demonstrate the error in Excel 97, 2000, 2002 and
2003:
Sub NewSheet()
'This statement produces Run-time error 1004, Method 'Add' of object
'Sheets' failed
Worksheets.Add Type:="C:\VBA\Temp\Sheet1.xlt"
Sheets.Add Type:="C:\VBA\Temp\Sheet1.xlt" 'This statement works
End Sub
--
Dave Peterson
|