Here are my favorite five recommendations for improving Visio performance in an app:

  1. Get a Cell by its location rather than its name:  Retrieve a cell by its Section, Row, and Cell location in the ShapeSheet using CellsSRC, rather than by Cell name. It also means that you’re more globalization-friendly (unless you’re using CellsU) since cell names are localized. Check the Visio Automation documentation for the CellsSRC method to find the Section, Row, and Cell indices. The Visio 2003 SDK has examples in the Code Librarian in C#, VB.NET, and VB for how to use CellsSRC.
  2. Add multiple shapes in a single call: Rather than dropping individual shapes onto a page, use the DropMany or DropManyU methods. This is especially important for .NET solutions, since you want to minimize how many times you cross process boundaries. Drop Many/DropManyU drops multiple shapes on a page, in a master, or in a group. It returns an array of the IDs of the Shape objects it produces. The Visio 2003 SDK has examples in the Code Librarian in C#, VB.NET, and VB for how to use DropMany/DropManyU.
  3. Set multiple formulas and results in a single call: SetFormulas and SetResults let you set multiple formulas and results (respectively) in one call. Again, this is important for .NET applications especially to minimize traffic across processes. To use this, you’ll need the shape ID's, which you can retrieve after calling DropManyU. Check the Visio 2003 SDK Code Librarian called "Get Many & Set Many Formulas" for a C#, VB.NET, and VB sample.
  4. Defer the application’s recalc: Visio is one big recalc engine, and recalc is an expensive operation. Turn on Application.DeferRecalc so that the ShapeSheet does not recalculate each time that shapes are dropped or cells have changed. Remember to turn off the property after you get done with your bulk drawing creation or edits.
  5. Drop all shapes first to any random location: It is faster to drop all your shapes in a random location on a page and then reposition them as needed.

Oh, and one more thing – if you are using the Visio 2003 ActiveX Control in a custom application, *do not* use shapes that have gradient fills with the application. There is a known issue where the ActiveX control’s performance seriously degrades when used with shapes with gradient fills. We’ll fix this in upcoming releases but for now, remove the gradients for your shapes.

 

-- Mai-lan

 

This posting is provided "AS IS" with no warranties, and confers no rights.