View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Tim Wallace Tim Wallace is offline
external usenet poster
 
Posts: 5
Default cannot shift objects off sheet

Here is my code, boiled down to the pertinent parts:

<snippet
Microsoft.Office.Interop.Excel.ApplicationClass excel = new
Microsoft.Office.Interop.Excel.ApplicationClass();

// open the template
Microsoft.Office.Interop.Excel.Workbook workbook =
excel.Workbooks.Open(_sTimesheetTemplate, System.Type.Missing, false,
System.Type.Missing, System.Type.Missing, System.Type.Missing, true,
System.Type.Missing, System.Type.Missing, true, System.Type.Missing,
System.Type.Missing, false, System.Type.Missing, System.Type.Missing);

if( workbook != null )
{
// get reference to the worksheet
Microsoft.Office.Interop.Excel.Worksheet sheet =
(Microsoft.Office.Interop.Excel.Worksheet)excel.Ac tiveSheet;

// insert a row after the current row (iRow starts where the first line
item should go and increments for additional rows)
sheet.Rows.Insert( Microsoft.Office.Interop.Excel.XlDirection.xlUp,
iRow )

</snippet

As you can see, nothing exotic is happening.

Tim

"George Nicholson" wrote in message
...
If you don't get the error message when inserting manually, but do get it
when inserting via code, then the code becomes prime suspect.
You might consider posting it.

--
George Nicholson

Remove 'Junk' from return address.



"Tim Wallace" <twallace-ThisDoesNotBelong-AT-emailDOTcom wrote in message
...
Jim:

No, I can manually insert. I have no special objects. I still get the
error.

Tim

"Jim Rech" wrote in message
...
Can I assume that you get the same error message when you insert rows
manually? Do you have any objects on the sheet? (Press F5, select
Special,
click Objects and click OK). If you have some they will be selected.
Press
Del to delete them (you're not going to save this so go ahead). Still
have
the problem?

This will not select cell comments, which is a leading cause of this
problem. But then you don't have any so no matter.

--
Jim
"Tim Wallace" <twallace-ThisDoesNotBelong-AT-emailDOTcom wrote in
message
...
| I've posted this problem in some C# groups, but after a couple of
days,
I've
| not gotten any useful responses. So, here goes again.
|
| I have a C# application from which I need to open an Excel (2003
| 11.6255.6360 SP1) sheet, insert some rows and then leave open for the
user.
| I have no hidden rows or columns. I have no comments. (these facts
are
so
| I don't get pointed to unapplicable Knowledge Base articles).
Whenever I
| attempt to insert a row, I get a "cannot shift objects off sheet"
error,
| even though all of the columns are visible and within the print area
and
| there are 8 blank rows visible and in the print area. Can anyone lend
a
| hand in figuring this out?
|
| I'm really at wits end on this, as this is the only thing keeping me
from
| completing my project, and I've been at it for a number of days now.
|
| Tim
|
|