TIP: Visio Auto Layout from C#

I couldn’t find this anywhere on the web, and needed some help from Visio team to figure it out, so here it is. If you want to get your shapes to layout using left-to-right flowchart format, use the CellsU property on the pagesheet:


Document doc = app.Documents.Add(”");
Page page = doc.Pages[1];
page.PageSheet.get_CellsU(”PlaceStyle”).FormulaU = “2″;
page.PageSheet.get_CellsU(”RouteStyle”).FormulaU = “6″;
// code to drop and glue all the shapes
page.Layout();


The numbers are the constants for layout style from the SDK.

Leave a Reply