View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
George Nicholson[_2_] George Nicholson[_2_] is offline
external usenet poster
 
Posts: 170
Default cannot shift objects off sheet

I'm not that familiar with .Net but in context of an Insert
"XlDirection.xlUp" is jumping up and sticking out its tongue at me (i.e., it
simply looks wrong).

"Up" might be an OK "shift direction" command when Deleting, but not when
Inserting. Example: if you are on row 2 and tried to insert a row "up" where
would you expect row 1 to go? Off the sheet? As I recall that's pretty much
what your original error message told you it couldn't do.

The Excel VBA Help entry for the Insert method says the *valid*
xlInsertShiftDirection constant options for use with the Insert method are
xlShiftToRight or xlShiftDown. In the context of Inserting a Row, only
xlShiftDown would seem to make any sense. I can only make an educated guess
that the equivalent via Interop is xlDown.

HTH,
--
George Nicholson

Remove 'Junk' from return address.



"Tim Wallace" <twallace-ThisDoesNotBelong-AT-emailDOTcom wrote in message
...
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
|
|