Search code examples
add-invisiooffice-addins

Building a VISIO addin to show relevent data on shape selection by creating rectangle and include text in it


Visio.Page visioPage = this.Application.ActivePage;
//Create a rectangle
Visio.Shape details = visioPage.DrawRectangle(45, 45, 45, 45);
Visio.Selection selection = Window.Selection;
            foreach (dynamic item in selection)
            {
                Visio.Shape shp = item as Visio.Shape;
                if (shp != null)
                {  
                   //Dropping Rectangle on to the page
                   visioPage.Drop(details, 50, 50);
                }
 }

Trying above code to create an rectangle on a visio inside Application_SelectionChanged Event. However,Not able to see rectangle on Visio. Please point out mistake here or any pointers regarding the same.


Solution

  • Your rectangles appear to have zero width and height. May this be the reason? DrawRectangle accepts x1, y1, x2, y2 coordinates.