excel.h - Automating Excel... How to Create new worksheets

J

Jona

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.
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
 
S

shadowman

Jona said:
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.
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
Try microsoft.public.excel.programming
 
V

Victor Bazarov

Jona said:
Hi, I'm trying to create new Worksheets in my code but I really have
no clue how to...

Neither do we. There is no definition of "Excel" or "worksheet" in
C++ _language_. You need to ask in the newsgroup dedicated to Excel
and/or whatever toolkit you're using. Try the 'microsoft.public.*'
hierarchy.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top