MadMaxx Posted May 11, 2005 Posted May 11, 2005 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. Quote
mark007 Posted May 11, 2005 Posted May 11, 2005 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 :) Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
mark007 Posted May 12, 2005 Posted May 12, 2005 No problem. :) Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
Recommended Posts