Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting mIssing arguments to Excel

Status
Not open for further replies.

RJMS

Programmer
Oct 9, 2002
3
GB
Can anyone help !

My task is quite easy (or should be), all I want to to do is to add a worksheet to an Excel workbook - but after all existing sheets.

It is easy enough to add a sheet in the default position - before the active sheet using;

m.oleapp.activeworkbook.worksheets.add()

The thing is I need to use arguements to the add method, but I don't need the first ("before") argument, in theory I should just leave it blank;

m.oleapp.activeworkbook.worksheets.add(,m.sheet_count,1,-4167)

where m.sheet_count is the (already established) number of sheets in the workbook but this causes Excel to generate an error, I've tried NULL, a space and a few other things besides - nothing works - it must be possible somehow !

Thanks
 
RJMS

Take a look at faq184-4266 (at the bottom) it shows you how to add a worksheet and how to move a worksheet.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks

It looks like the missing argument was not in fact the problem - I can use

m.activeworkbook.worksheets.add(,m.activeworkbook.worksheets(m.sheet_count))

So it looks like the type of the other arguments was the problem.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top