Macro Recorded to Add Sheet Template Incorrect (139575)
The information in this article applies to:
- Microsoft Excel for Windows 95
This article was previously published under Q139575 SYMPTOMS
When you record a Visual Basic for applications macro that adds a sheet
template to a Microsoft Excel version 7.0 workbook, you will get a line of
code similar to the following:
Sheets.Add Type:= "C:\MSOFFICE\TEMPLATES\SHEET.XLT"
When you run this code, you receive the following error message:
Run-Time Error '1004' Add method of sheets class failed
CAUSE
The value for the Type argument must be a Microsoft Excel sheet constant.
The sheet constants are as follows:
xlWorksheet
xlChart
xlModule
xlDialogSheet
xlExcel4MacroSheet
xlExcel4IntlMacroSheet
WORKAROUND
To work around this problem, use the following steps:
- Save the template as Sheet.xlt in your Excel\Xlstart folder.
- Restart Microsoft Excel.
Now you can record the macro to insert the template and the recorded macro.
STATUS
Microsoft is researching this problem and will post new information here in
the Microsoft Knowledge Base as it becomes available.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbProgramming KB139575 |
---|
|