I was wondering what kind of types of Value2 can be returned. I am asking this question since it seems that the type of Value2 is always an object, but the actual underlying type does not always seem to be the same. For example: given that cell A1 contains “1234”, the following line of code fails on my computer:
string targetValue = (string)Application.get_Range(“A1”).Value2
However, if the cell A1 contains “abcdef”, the previous line succeeds. Now, I have seen the type double and the type string. My question is, are there more possible types that can result in an error? Does Value2 have for example integers? Or have I caught them all?
I have read the documentation, but I can't seem to find all possible supported types.
PS: I am using Visual Studio 2017, Excel 2016 and C# to create my add-in.