Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Creating Workbook with 2 worksheets

Hi,

I am using Automation with VC++ 6 to create and write to a spreadsheet.

I use the following to create it :-

COleVariant
covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);


// Start Excel and get Application object.

if(!m_objApp.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Couldn't start Excel and get Application object.");
//return;
}

m_objBooks = m_objApp.GetWorkbooks();
m_objBook = m_objBooks.Add (covOptional);

This code creates a workbook with 3 work sheets. Is it possible to define
how many worksheets are created when i first create my workbook? e.g 2
worksheets?

Thanks In Advance
Macca
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Creating Workbook with 2 worksheets

There is a setting:
eg.
Application.SheetsInNewWorkbook = 2
(That's VBA, not C++)

However, this is a preference for the user which is saved as Excel is
closed.
When the user next opens Excel, they'll get as many sheets as you last set.

If I want to create a book with 2 sheets then I write code to add sheets if
they are missing, remove sheets if there are too many.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Macca" wrote in message
...
Hi,

I am using Automation with VC++ 6 to create and write to a spreadsheet.

I use the following to create it :-

COleVariant
covTrue((short)TRUE),
covFalse((short)FALSE),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);


// Start Excel and get Application object.

if(!m_objApp.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Couldn't start Excel and get Application object.");
//return;
}

m_objBooks = m_objApp.GetWorkbooks();
m_objBook = m_objBooks.Add (covOptional);

This code creates a workbook with 3 work sheets. Is it possible to define
how many worksheets are created when i first create my workbook? e.g 2
worksheets?

Thanks In Advance
Macca



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Creating Workbook with 2 worksheets


or do this?..

dim lSNW&
lSNW = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 2
workbooks.add
Application.SheetsInNewWorkbook= lSNW





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob van Gelder wrote :

There is a setting:
eg.
Application.SheetsInNewWorkbook = 2
(That's VBA, not C++)

However, this is a preference for the user which is saved as Excel is
closed.
When the user next opens Excel, they'll get as many sheets as you
last set.

If I want to create a book with 2 sheets then I write code to add
sheets if they are missing, remove sheets if there are too many.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Creating Workbook with 2 worksheets

True... Why didn't I think of that? ;) Sometimes I do things the hard way

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"keepITcool" wrote in message
...

or do this?..

dim lSNW&
lSNW = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 2
workbooks.add
Application.SheetsInNewWorkbook= lSNW





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob van Gelder wrote :

There is a setting:
eg.
Application.SheetsInNewWorkbook = 2
(That's VBA, not C++)

However, this is a preference for the user which is saved as Excel is
closed.
When the user next opens Excel, they'll get as many sheets as you
last set.

If I want to create a book with 2 sheets then I write code to add
sheets if they are missing, remove sheets if there are too many.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Creating Workbook with 2 worksheets

Thnaks for the replies.

Do you know how i add/remove using VC++ rather than VBA?

Cheers
Macca


"Rob van Gelder" wrote:

True... Why didn't I think of that? ;) Sometimes I do things the hard way

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"keepITcool" wrote in message
...

or do this?..

dim lSNW&
lSNW = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 2
workbooks.add
Application.SheetsInNewWorkbook= lSNW





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob van Gelder wrote :

There is a setting:
eg.
Application.SheetsInNewWorkbook = 2
(That's VBA, not C++)

However, this is a preference for the user which is saved as Excel is
closed.
When the user next opens Excel, they'll get as many sheets as you
last set.

If I want to create a book with 2 sheets then I write code to add
sheets if they are missing, remove sheets if there are too many.






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
Combine worksheets in multiple workbook in one workbook with a macro Sam Commar Excel Discussion (Misc queries) 2 April 2nd 09 01:09 PM
Creating lists from multiple worksheets within one workbook... Corey Excel Discussion (Misc queries) 1 June 28th 07 08:16 PM
Help creating workbook with worksheets "linking" cells Trulife Excel Worksheet Functions 0 March 18th 07 11:00 PM
Creating a List From Worksheets in a WorkBook Carl Excel Worksheet Functions 1 August 30th 06 09:00 PM
Sort Numerically Worksheets via VB when creating a new worksheets John Excel Programming 6 June 1st 04 07:21 AM


All times are GMT +1. The time now is 02:22 PM.

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"