I have a named cell in excel lets say its called "myCell" In C# I wish to be able to access this cell and update its value. I've tried
Globals.ThisAddIn.Application.Names.Item(@"myCell").Value = "myValue";
But this throws a COM exception with the message 'Exception from HRESULT: 0x800A03EC'
Your problem is that:
Globals.ThisAddIn.Application.Names.Item(@"myCell")
does not return a Range for which you can set the value, but an object of type Name. You can get the Range representing the cell you are looking for using the RefersToRange property and then set the value for this object. This all translates into something like this:
Globals.ThisAddIn.Application.Names.Item(@"myCell").RefersToRange.Value = "myValue";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With