Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey all,

 

I'm new to the whole office integration side of VS.NET. I have to open an excel file, dump data into it and then print it.

 

The problem is that I can't for the life of me figure out how to insert a column. When I try I keep getting the same error.

 

Here is where it errors out.

 

oSheet.Columns.Insert(Excel.XlInsertShiftDirection.xlShiftToRight,False)

 

The error message says that it can't shift non blank cells off the worksheet.

 

I know how to put data in but this is the only part that is holding me up.

 

Thanks to anyone who replys.

Posted

Where are you actually wanting to add the column?

 

I think you need to specify it i.e.:

 

 

oSheet.Columns(2).Insert(Excel.XlInsertShiftDirection.xlShiftToRight,False)

 

To insert a column in at col B etc.

 

You could also use:

 

oSheet.Range("b2").EntireColumn.Insert(Excel.XlInsertShiftDirection.xlShiftToRight,False)

 

etc.

 

HTH

 

:)

Please check the Knowledge Base before you post.

"Computers are useless. They can only give you answers." - Pablo Picasso

The Code Net

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...