Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default excel.h - How To? Add a new worksheet c++

Hi, I'm trying to create new Worksheets in my code but I really have
no clue how to...
here is part of my code.
the code I'm is really the one from this webpage: http://support.microsoft.com/kb/178781
but the problem is that they say nothing about creating a new
Worksheet.

Thanks for your help in advance.

//Header declarations..
_Application xlApp;
Workbooks wb;
_Workbook _wb;
Worksheets ws;


//Source
//Add Workbook
wb = xlApp.GetWorkbooks();
_wb = wb.Add(covOptional);
ws = _wb.GetSheets();


//Remove the 3 default sheets
_Worksheet selSheet;
selSheet = ws.GetItem(COleVariant((short)1));
selSheet.Delete();
selSheet = ws.GetItem(COleVariant((short)2));
selSheet.Delete();
selSheet = ws.GetItem(COleVariant((short)3));
selSheet.Delete();


If you want to rename any of these sheets is really easy//
selSheet = ws.GetItem(COleVariant((short)2));
selSheet.SetName("NonInteractive Mode Results");


-Jona

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel.h - How To? Add a new worksheet c++

On Jul 6, 11:40 am, Jona wrote:
Hi, I'm trying to create new Worksheets in my code but I really have
no clue how to...

[snip]

For the greater majority of Excel actions, you can find out how
to do them in VB through the Macro Recorder. Turn it on, do the
action manually, turn it off, then look at the code that Excel
created. If you need options, you can usually look them up
pretty easily in the Helps, once you have the hint that the
Macro Recorder gives you. So start with Tools Macro
Record New Macro...
Socks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default excel.h - How To? Add a new worksheet c++

Thanks, for the tip. I've tried that and it did give me a hint but
I'm still stuck with the add() function.

I really don't know what to put into this function... any ideas?
thanks!

this are the parameter that the add() function takes:

ws.Add( const VARIANT &Before, const VARIANT &After, const VARIANT
&Count, const VARIANT &Type );

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default excel.h - How To? Add a new worksheet c++

This is from Excel VBA help:

Before Optional Variant. An object that specifies the sheet before which
the new sheet is added.
After Optional Variant. An object that specifies the sheet after
which the new sheet is added.
Count Optional Variant. The number of sheets to be added. Teh default
value is one.
Type Optoinal Variant. Specifies sheet type. Can be on 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.


"Jona" wrote in message
ups.com...

Thanks, for the tip. I've tried that and it did give me a hint but
I'm still stuck with the add() function.

I really don't know what to put into this function... any ideas?
thanks!

this are the parameter that the add() function takes:

ws.Add( const VARIANT &Before, const VARIANT &After, const VARIANT
&Count, const VARIANT &Type );



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
compare excel worksheet and output difference to new worksheet Deb Excel Discussion (Misc queries) 1 October 31st 08 02:26 PM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet Aster Excel Worksheet Functions 3 March 12th 06 09:58 AM
excel 97: copy and paste values from one worksheet to another worksheet Kathy[_5_] Excel Programming 0 September 21st 03 03:03 PM
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet Ant Waters Excel Programming 1 September 3rd 03 11:34 AM


All times are GMT +1. The time now is 06:02 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"