com >> Adding Excel Worksheets

by Brent Stevenson » Fri, 10 Feb 2006 10:09:58 GMT

When using this code "Worksheets.Add after:=Worksheets(1)" to add a
worksheet I get an "Application-defined or object-defined error". I have the
MS Excel 11.0 Object Library referenced. If I remove the
"after:=Worksheets(1)" code the worksheet gets inserted in place of the
first worksheet.

Thanks in advance.




com >> Adding Excel Worksheets

by Suzette » Thu, 02 Mar 2006 01:55:46 GMT


Might be something else going on. I just tried it and it worked perfectly.









Similar Threads

1. Adding Excel Worksheet to existing Workbook using Access 97 Macro

Does anyone know how (if) you can add worksheet(s) to an existing Excel
workbook using an MS Access 97 macro?

2. How can I add Excel worksheet functions? (Financial) - Excel

3. Adding Excel Worksheets

Hi all,
I am developing an application to create an excel file with some worksheets 
in c++.
When i try to add a new worksheet in a position given by an index, i find a 
problem with the add method.
The problem is that I try to insert a new worksheet after the one which 
takes the (index-1) position, but the second parameter in the add method 
doesnt work

long index=2;
objSheets.Add(covOpt, COleVariant(index-1), covOpt, covOpt);
objSheet1=objSheets.get_Item(COleVariant(index));

I've also tried to put the worksheet object as the second parameter, but it 
doesn't work too:
objSheets.Add(covOpt, objSheets.get_Item(COleVariant(index-1))), 1, covOpt);

Thanks in advance for your help!


4. How to add excel worksheet ?

5. add Excel worksheet problem

6. Adding Excel Worksheets - Visual Basic/VB