Adding worksheet at the end of workbook.

Hi All,

I am working on excel automation using MFC.

I want to add one worksheet at the end of the current workbook. 

Currently I am using  Worksheets::Add(Before, after, Count,Type) method.
i am passing optional parameter like this:

COleVariant oOleVarOptional(DISP_E_PARAMNOTFOUND,VT_ERROR); 

_Worksheet  m_oNewSheet = m_oSheets.Add(oOleVarOptional,oOleVarOptional, 
oOleVarOptional, oOleVarOptional)

So it is adding the sheet before the current active sheet.

But i am not getting what to pass for "after" in order to add the sheet at 
the end.

Can anybody help me regarding this... ?
-- 
Thanks
Ash Jings
09/09/08
0
9/9/2008 10:20:01 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1158 Views

Similar Articles

[PageSpeed] 24

Is it so hard to look at MSDN?
From http://msdn.microsoft.com/en-us/library/aa221688(office.11).aspx :
`*************************
Creates a new worksheet, chart, or macro sheet. The new worksheet becomes 
the active sheet.


expression.Add(Before, After, Count, Type)

expression Required. An expression that returns one of the above objects.

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. The default value 
is one.

Type  Optional Variant. Specifies the sheet type. Can be one 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 isxlWorksheet.

Remarks
If Before and After are both omitted, the new sheet is inserted before the 
active sheet.

****************************

Victor

"Ash Jings" <jinagarashwini@gmail.com> wrote in message 
news:98F2846E-5E4E-46D6-AD9C-0EB1C15C9FFC@microsoft.com...
> Hi All,
>
> I am working on excel automation using MFC.
>
> I want to add one worksheet at the end of the current workbook.
>
> Currently I am using  Worksheets::Add(Before, after, Count,Type) method.
> i am passing optional parameter like this:
>
> COleVariant oOleVarOptional(DISP_E_PARAMNOTFOUND,VT_ERROR);
>
> _Worksheet  m_oNewSheet = m_oSheets.Add(oOleVarOptional,oOleVarOptional,
> oOleVarOptional, oOleVarOptional)
>
> So it is adding the sheet before the current active sheet.
>
> But i am not getting what to pass for "after" in order to add the sheet at
> the end.
>
> Can anybody help me regarding this... ?
> -- 
> Thanks
> Ash Jings
> 09/09/08 


0
9/9/2008 7:37:12 PM
Thank you Victor.
But your reply did not help me.

I found the solution in the following link

http://support.microsoft.com/kb/253501

-- 
Thanks
Ash Jings


"Victor" wrote:

> Is it so hard to look at MSDN?
> From http://msdn.microsoft.com/en-us/library/aa221688(office.11).aspx :
> `*************************
> Creates a new worksheet, chart, or macro sheet. The new worksheet becomes 
> the active sheet.
> 
> 
> expression.Add(Before, After, Count, Type)
> 
> expression Required. An expression that returns one of the above objects.
> 
> 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. The default value 
> is one.
> 
> Type  Optional Variant. Specifies the sheet type. Can be one 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 isxlWorksheet.
> 
> Remarks
> If Before and After are both omitted, the new sheet is inserted before the 
> active sheet.
> 
> ****************************
> 
> Victor
> 
> "Ash Jings" <jinagarashwini@gmail.com> wrote in message 
> news:98F2846E-5E4E-46D6-AD9C-0EB1C15C9FFC@microsoft.com...
> > Hi All,
> >
> > I am working on excel automation using MFC.
> >
> > I want to add one worksheet at the end of the current workbook.
> >
> > Currently I am using  Worksheets::Add(Before, after, Count,Type) method.
> > i am passing optional parameter like this:
> >
> > COleVariant oOleVarOptional(DISP_E_PARAMNOTFOUND,VT_ERROR);
> >
> > _Worksheet  m_oNewSheet = m_oSheets.Add(oOleVarOptional,oOleVarOptional,
> > oOleVarOptional, oOleVarOptional)
> >
> > So it is adding the sheet before the current active sheet.
> >
> > But i am not getting what to pass for "after" in order to add the sheet at
> > the end.
> >
> > Can anybody help me regarding this... ?
> > -- 
> > Thanks
> > Ash Jings
> > 09/09/08 
> 
> 
> 
0
9/10/2008 11:12:01 AM
Reply:

Similar Artilces:

Copy rows of data to another worksheet where ReturnDate is blank
I'm sure this is do-able within Excel but what formula I should use to accomplish it escapes me. Basically, I'm working with a spreadsheet which lists books checked out from our Resource Center. When the books are returned, the Return Date is entered in column D. I want to run a report showing everyone who has outstanding books without having to go through the spreadsheet, row-by-row, to copy the data to the worksheet "Outstanding." Thanks for your help! Try AutoFilter - Select Row 1, go to Data, Filter, AutoFilter. An arrow will appear at each cell in that row....

Adding Memory to Server
We are running GP 9 on Microsoft Serevr2003, SP1 on a dual processor Compaq server with 2 GB RAM An older document on GP 8 hardware requirements states the boot.ini file should enable the /3GB and/or /PAE switch if more than 2 GB RAM is available. Then the doc references Microsoft article 283037. This VERY confusing article appears to conflict itself regarding these two switches. And it also states the /3Gb and /PAE switches are used when more than 4 GB RAM is available. The article discusses dramatic performance problems when RAM switches are not correctly set. I was unable to fin...

merging two worksheets into one pivot chart
I�m trying to merge to worksheets into one pivot chart. But i someho don�t get to choose which fields I can put where in the table. If I us the multiple consolidated option the wrong items are put on th horizontal axis. What am i doing wrong -- Kirstyko ----------------------------------------------------------------------- Kirstykop's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2538 View this thread: http://www.excelforum.com/showthread.php?threadid=38861 You're not doing anything wrong. If you create a Pivot Table from multiple consolidation ranges, a...

Need to resize a worksheet window
I have Excel 2002, and need help resizing a worksheet window. My problem is with a worksheet window that, when minimized, is so tall the worksheet tabs cannot be displayed at the bottom (when it's maximized they show just fine, but I need to work with it minimized). Even when I move the worksheet window up as far as I can on the screen, I still cannot reach the bottom border to resize it. Is there a way around this? -- Hasta Pasta Hasta, I think you mean restored, not minimized. The middle button. Restored is a variable-sized window. Minimized is just an icon (left button). ...

using multiple worksheets to do calculations
I am set an assignment for capital expenditure and i need to create a input, formulas and output in different worksheets. The reason why w have to use multiple worksheets is we want to be able to change figure in the input worksheet and in doing so the output workshee should change at the result of this. For example say in the input worksheet i have a cell with IRR=40 and in the formulas worksheet i have 1/(0.5 + IRR)^1 in one of th cells if i change 40 to 41 then the output worksheet will contain a differen answer I want help on transfering the input number (IRR) from the inpu worksheet to...

Creating Outbound Call Camapign and Assiging to end user
I have only just started to use MS CRM 3. I have purchased MS Press 'Working with MS CRM 3' but can't find a resolve for my problem. I am trying to create an outbound campaign for our sales reps to call a selection of of customers with an offer. I create a campaign, create activities for phone call, attach a marketing list previously selected. Set the status to launch. When our sales people log they can see the campaign in there list of activities but the status for them is set to pending. What I was hoping for was when the sales person logged in they would see a list of ca...

Retrieve Deleted Worksheet
I did something very stupid. I deleted a worksheet from a workbook. I thought to myself: there are too many worksheets in this workbook. That one is blank, so I'll delete it. Unfortunately, there are some important macros stored in that worksheet and I don't have another copy of them. Is there any way to retrieve them? Thanks very much If you have not saved the file close it without saving, if you have not backed up the file other places to look for a copy, have you e-mailed it? May be a copy in your sent items folder, if file was on a network server it probably makes backups a...

Sharepoint error adding Webpart
Hello. When I go to the Webpart Gallery and click "New", I get a "File Not Found" error. Any thoughts? Thanks inadvance, Mike Nevermind. It was the Smartpart webpart. After removing it everything is file. "milop" <milop@slomins.com> wrote in message news:%23zm1nV0oKHA.5776@TK2MSFTNGP04.phx.gbl... > Hello. > > When I go to the Webpart Gallery and click "New", I get a "File Not Found" > error. > > Any thoughts? > > Thanks inadvance, > > Mike > ...

Excel4 Workbook Wont run in Excel XP
Hi my experience in Excel is limited but have a major problem. Have been given a excel workbook that is used for producing results for downhill skiing competitions. The sheet lets you put all the competitors details in and then their basic seeding points. By the push of a button it will let you set up each race and then print out the start positions. After each race it will let you put in the times and then calculate by the push of a button the seed positions and the start order for the next race etc. until the whole competition is finished then it will let you print all the overall result...

Adding a KeyID column for sorting
Hi. I'm using MS Windows XP (Home) and Excel 2003. I have a worksheet with five columns and about 10,000 rows. I intend to do a lot of sorting on these columns. However, I want to be absolutely certain that the original order is always maintained (why I'm not using MS Access is a long story -- suffice it to say that I need to use Excel). So after I do a sort and perform a few tasks I want to click on a KeyID column and see the original order that I had before the sorting. Occasionally I will add a few rows of new material -- say between rows 100 and 120, or between 3330 an...

personal workbook #2
What is this workbook?where is it located?how do I open it ?why is it used for? AFD It is located in the XLStart directory, and is used to store macros an d things that you want to be available to all workbooks, whenever you start Excel. You can create it b y - goto Tools>Macros>Record New Macro... - Choose Personal Macro Workbook form thr dropdown - OK - click the Stop button on the toolbar that pops-up You now have a Personal.xls workbbok. It is not visible though, it is hidden by default (Windows>Unhide) -- HTH Bob Phillips (remove nothere from email address if mailing d...

Locating Formulas within a Worksheet
I need to locate a formula that is trying to update wheneven I open particular spreadsheet. Is there a way to find all formulas within worksheet? The spreadsheet has only one worksheet with approximately 2000 rows an about 40 columns. It is not really a large spreadsheet comparativel speaking, but locating the formula manually (moving to each cell) woul take a lot of time. I cannot copy all and paste values as some cell must remain active formulas. I run into this problem once in a while. Any help would be appreciated -- Message posted from http://www.ExcelForum.com Hi try: - select you...

Summarize a range referenced in a separate worksheet
What is the best way to add a sum in Worksheet #2 for a range of data in Worksheet #1. Example. Worksheet #1 Date Week # $$ 1/1/10 1 10.00 1/2/10 1 10.00 1/3/10 1 10.00 Worksheet #2 Week $$ Total 1 30.00 (looking for a formula to populate this field) Thanks. =SUMIF('Sheet 1'!B:B,1,'Sheet 1'!C:C) -- Best Regards, Luke M "nitengale" <nitengale@discussions.microsoft.com> wrote in message news:2E7A195E-B5C0-44E3-BC59-CECC40D8DC79@microsoft.com... > ...

How can I insert a value from an Excel Worksheet into a footer?
I have a workbook with several tabs and would like to have a value in the footer that is stored in a "control information" tab so don't have to enter it in the footer for each tab. Did you know that if you select all sheets(right-click on one and "select all sheets") you can set most print options including headers and footers? If you wish a macro...... Sub CellInFooter() Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets ws.PageSetup.CenterFooter = Sheets("Sheet1").Range("A1").Text Next ws End Sub Gord Dibben Excel MVP On T...

SP2 woes
I've upgraded to E2K SP2 but I didn't see the advice to upgrade front-end servers first. Now OWA doesn't work properly and I'm not sure what to do. What steps do I need to take to get our front-end server to SP2? Thanks Just install SP2 on your Front-end server would be what I would assume here. The install is the same regardless of whether it is a FE or BE server. -- Ben Winzenz Exchange MVP MessageOne "PS" <smythp@kynetix.com> wrote in message news:ua3xH4D7FHA.2576@TK2MSFTNGP09.phx.gbl... > I've upgraded to E2K SP2 but I didn't see the ...

Adding a list box in place of a cell
I have a inherited a status spreadsheet that is updated ofen Previously, the sheet was saved by date so if you wanted to view th history of the comment field/column you had to open each spreadsheet. would like to append history but not have the cell grow to an enormou size. My thought is to use a list box but what I want to do is keep th box a static size and scroll through the data. I can use a secondar sheet to store and modify the data. TI -- Message posted from http://www.ExcelForum.com Found the solution. I need to use textbox instead of list box. Then set vertical scrollbars to 2 - f...

In Excel 2000, How do you select the whole of a worksheet (Select. #2
In Excel 2000, How do you select a whole worksheet (Select All) with ONE click of the mouse? Cheers!! Click the little gray button above Row One and to the left Column A. tj "Rascal" wrote: > In Excel 2000, How do you select a whole worksheet (Select All) with ONE > click of the mouse? Cheers!! ...

calling up a workbook
In my macro I do a 'save as', in which the program calls for the 'save as' by a variable (called 'stage_name'). I save the sheet - don't close it - go on with another sheet and do another save as (by a variable 'stage_order'). Now I want to activate the workbook stage_name. It doesn't work what am I doing wrong? Here is what my macro looks like : 'prompt for a save as.... Do OrderFormName = Application.GetSaveAsFilename(InitialFileName:="Sales Order_Rep Name", _ fileFilter:="Microsoft Excel (*.xls), *.xls") ...

domain user deleted / added again (SID problem in CRM)
Hi All, We have a domain user that needed to be deleted from AD, and added again. The problem is that the user was added as CRM user, and now when I try to install CRM client, it says that the user cannot be logged on CRM. I checked in CRM, and the user is there. So I suppose that the problem is in the new SID the user got when being created for the 2nd time. How do I change the user in CRM, or delete and recreate the user there? Any suggestions? Thanx in advance, and regards from Zoran Get the original user's SID and then add it to new user account's SID history - if you...

adding newsgroup to outlook
Hi, Had to reinstall a lot of things. I know there is a way to add newsgroups from OE to the bar in outlook. Do not remember how though? help thanks "Bruce Leavitt" <Notthis1@noidea.com> wrote in message news:%23UedXarjIHA.4684@TK2MSFTNGP06.phx.gbl... > Hi, > Had to reinstall a lot of things. I know there is a way to add newsgroups > from OE to the bar in outlook. Do not remember how though? > help > thanks > Outlook doesn't do news - you open OE in Outlook Newsreader mode with Go-News. I know, Outlook does not do news, But, you can add an ic...

Informatica Connect to Excel workbook
READER_1_1_1> DBG_21438 Reader: Source is [Romania:Romania], user [PMNullUser] I'll try to connect to an excel workbook with different country sheets containing data, which I want to load into our DWH. Now I'm getting the following error : READER_1_1_1> Fri Dec 03 09:29:24 2004 READER_1_1_1> RR_4036 Error connecting to database [ [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified Database driver error... Function Name : Connect Database driver error... Function Name : Connect Database Error: Failed to connect to database using user...

creating dymanic mirrored worksheets
I have project where I import (via Word Automation) text content into a Excel template. All text, no calculations. I want to have a second worksheet which mirrors certain columns from sheet 1. Here is the problem. How can I have both worksheets dynamic at the same time? If I enter data in worksheet one, I want the data to appear in the same cell row (like-named column). This I can do. But what want is to have worksheet 2 also dynamic so when I enter data into a row, it appears in the like-named column on worksheet 1. In other words, I want to be able to enter data in either sheet, and the...

5.5 to 2003 migration: AD connector
I could use confirmation on a couple of items of our 5.5 to 2003 migration. 1) Once I have gone through the steps on KB article 822450 "Removing the last 5.5 computer from an Exch 2003 admin group", am I safe to manually delete the 3 connection agreements in AD Connector Services on my Exch 2003 box (Config CA, Public Folders, Users)? 2) At this point, am I also safe to delete the Microsoft Exchange Site Replication Service in Exch 2003 System Manager? Any info is greatly appreciated. I'm having a hard time finding answers to these points. Regards, Steve ...

Free classified post ad
Market place in the important think of merketing. So increase your sales, be a great business man.place an ad. please visit www.adplacebd.com - advance classified of bangladesh. ...

Can't get account added back in
I accidentally deleted one of my accounts in Money. That account was at a bank where I have several other accounts. I'm not able to get that one account added back into Money. Following are the steps I've taken several times over the course of the last few days. Can anyone see what I 'm doing wrong? New Account \ Choose bank \ Check "Yes" for "the new account uses the same sign-in information." \ Checked OK for Updating the bank's current info (had updated it about 3 minutes previously...) \When it says 'update' complete, I click DONE. I...