Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Worksheets.Add won't let me specify a template

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Worksheets.Add won't let me specify a template

I got the same problem xL2002. I usually use the workbooks.add template
method which works OK. But it is worth noting this inconsistency. Thanks

--
Cheers
Nigel



"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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Worksheets.Add won't let me specify a template

Interestingly, in Excel 2003 the Worksheets.Add Type:= statement will accept
three of the four XlSheetType constants: xlWorksheet, xlExcel4MacroSheet, or
xlExcel4IntlMacroSheet. It fails on xlChart.
--
Brad
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Worksheets.Add won't let me specify a template

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Worksheets.Add won't let me specify a template

XL2004?

We've done 2004 Dave!

Bob


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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Worksheets.Add won't let me specify a template

er, I meant xl2006!

(Isn't xl2004 for the mac?)

Bob Phillips wrote:

XL2004?

We've done 2004 Dave!

Bob

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


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding additional worksheets to an existing template Mike F Excel Discussion (Misc queries) 2 November 20th 08 07:18 PM
How do use a template for different worksheets in workbook peggy Excel Worksheet Functions 1 October 17th 08 04:53 AM
How do I import and filter worksheets into a template? fab Excel Discussion (Misc queries) 1 October 15th 06 08:06 PM
New Worksheets in a template to be pre-formatted. Mohan De Silva Excel Worksheet Functions 1 December 23rd 05 01:53 AM
Paste data repeatedly from different worksheets to a template Mike Krauss Excel Worksheet Functions 0 May 19th 05 07:50 PM


All times are GMT +1. The time now is 12:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"