Calling this[int index] via reflection
- by tkutter
I try to implement a reflection-based late-bound library to Microsoft Office.
The properties and methods of the Offce COM objects are called the following way:
Type type = Type.GetTypeFromProgID("Word.Application");
object comObject = Activator.CreateInstance(type);
type.InvokeMember(<METHOD NAME>, <BINDING FLAGS>, null, comObject, new object[] { <PARAMS>});
InvokeMember is the only possible way because Type.GetMethod / GetProperty works improperly with the COM objects.
Methods and properties can be called using InvokeMember but now I have to solve the following problem:
Method in the office-interop wrapper:
Excel.Workbooks wb = excel.Workbooks;
Excel.Workbook firstWb = wb[0];
respectively
foreach(Excel.Workbook w in excel.Workbooks)
// doSmth.
How can I call the this[int index] operator of Excel.Workbooks via reflection?