Keith

Keith

  • NA
  • 13
  • 0

Method() is inaccessible due to its protection level

Jan 31 2014 4:50 PM
Hi All,
 
I'm only self taught (as most are I'm sure), but I only deal with small apps to help out at work. I'm reading data from an Access Database, performing my report functions on it, and saving it to Excel. This all works fine, but I am trying to format the column width in the spreadsheet, but receive the error 'System.Data.Range' is inaccessible due to its protection level in the following code:

public void
SetColumnWidth(Excel.Worksheet ws, int col, int width)
{
    ((Range)ws.Cells[1, col]).EntireColumn.ColumnWidth = width;
}
 
I'm sure you will need more information, but I'm unsure what. If you can tell me I'll post it ASAP.
 
Thanks is advance!

Answers (2)