Accessing of Custom properties of MFC controls in Excel using VSTO
-
Tuesday, June 05, 2012 8:51 PM
I am trying the following code.
Microsoft.Office.Tools.Excel.Worksheet _worksheet = _vSTOWorkbook.GetActiveToolsWorksheet(_applicationFactory);
Shape _shape = _worksheet.Shapes.AddOLEObject("<My MFC Activex control>");
_shape.OLEFormat.Object.<CustomProperty> = <value>;While setting the custom property, I am getting RuntimeBinder exception. Is there any other way to achieve what I am trying to get?
Thanks.
M Sharma, Deloitte, USA
All Replies
-
Wednesday, June 06, 2012 5:21 AM
Hi M Sharma,
I don't think your snippet will work fire for following options:
- MFC controls can't access directly in the .NET Framework.
- You need wrap your control via .NET Framework in order to let it can be access in .NET Framework program.
Have a good day,
Tom
-
Wednesday, June 06, 2012 8:57 AMmaybe try to generate interop type for your com object and cast OLEFormat.Object to this interop type.
-
Wednesday, June 06, 2012 3:42 PMThanks Tom but the same snippet works perfect in Word. Any specific reasons you can think of?
M Sharma, Deloitte, USA

