Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / May 2006

Tip: Looking for answers? Try searching our database.

Range Insert method - CopyOrigin parameter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
njappboy - 25 May 2006 20:02 GMT
Does anyone have more information on the CopyOrigin parameter of the
NamedRange.Insert method?

I'm using VSTO 2005 and the task I'm trying to perform in Excel 2003 is
simple.

I have a NamedRange object, declared Globally, called reqItemRange.  It
spans 1 row and 18 columns, (A2:R18).  I'm simply trying to insert a new row
into the top of the range.  On an Action Pane there is a button that calls
the following code in its onclick event.  I also redefine the NamedRange
using the RefersToR1C1  property (this works).

               int startRow = 2;

               Excel.Range startCell =
(Excel.Range)Globals.Sheet1.Cells[startRow, 1];
               startCell.Select();
               int row = 0;
               row = Globals.Sheet1.reqItemRange.Row;
               
Globals.Sheet1.reqItemRange.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown, System.Type.Missing);
              Globals.Sheet1.reqItemRange.RefersToR1C1 = "=R" +
startRow.ToString() + "C1:R" + (Globals.Sheet1.reqItemRange.Rows.Count +
(Globals.Sheet1.reqItemRange.Row - 1)).ToString() + "C18";
               
               startCell.Select();

The first click of the button performs well, although the new row doesn't
contain the drop-down lists in the cells that were in the original row in the
NamedRange.  Subsequent clicks on the button causes multiple new rows to be
added.  The number of rows added seems to be equal to the number of rows
previously in the NamedRange  before clicking the button.  I've tried
substituting different values for the Insert methods second argument (object
CopyOrigin).  

For example, if I pass -1 as the CopyOrigin argument the Insert does copy
the drop-downs in the original range's rows but the multiple row additions
still occurs on subsequent button clicks.  If I pass 0 as the CopyOrigin
argument the Insert doesn't copy the drop-downs and still adds multiple rows
on susequent clicks.

Does any know what this CopyOrigin argument actually does?

Signature

Somewhere on the Delaware River

njappboy - 30 May 2006 19:09 GMT
It would seem that the CopyOrigin parameter is supposed to be an enumeration
of the type Microsoft.Office.Interop.Excel.XlInsertFormatOrigin .  Someone at
Redmond needs to update the Insert method docs with this bit of information.

Signature

Somewhere on the Delaware River

> Does anyone have more information on the CopyOrigin parameter of the
> NamedRange.Insert method?
[quoted text clipped - 38 lines]
>
> Does any know what this CopyOrigin argument actually does?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.