This is a mirror of official site: http://jasper-net.blogspot.com/

ComObject Visualizer

| Wednesday, April 21, 2010
Recently I worked on a project which dealt with Excel and PowerPoint applications and encountered the impossibility to view type of COM object while debugging. I tried to use GetType but it returned a __ComObject  which by itself doesn’t contain any helpful information about underlying interface.

I’ve decided to create a visualizer for Visual Studio, which helps to work with COM objects while debugging. Therefore this article will describe a way to identify supported by COM object interfaces.
Background

Below is an example of code which finds a shape in Excel and casts it to TextBox, a control of Office.Forms:

 using Microsoft.Office.Interop.Excel;
 using TextBox=Microsoft.Vbe.Interop.Forms.TextBox;
 ...


       Shape shape = sheet.Shapes.Item("ctool");
       OLEObject oleObject = (OLEObject) shape.OLEFormat.Object;
       TextBox TextBox = (TextBox) oleObject.Object;
       ...

Read more: Codeproject

Posted via email from jasper22's posterous

0 comments: