“object does not contain a definition for get_Range” in Excel C#


Error:
‘object’ does not contain a definition for ‘get_Range’

Line of Code:
Excel.Range header = wks.get_Range(wks.Cells[1, 1], wks.Cells[1, 10]);
Solution:
Cast the cells as "object" in get_Range()

Excel.Range header = wks.get_Range((object)wks.Cells[1, 1],(object) wks.Cells[1, 10]);

Thanks!

(157)

4 thoughts on ““object does not contain a definition for get_Range” in Excel C#”

Leave a Reply

Your email address will not be published. Required fields are marked *