When to Supplement Visio Formulas with Automation

One of the more important questions in developing a Microsoft® Visio® solution is this: When should you supplement formulas with Automation? Visio formulas can be extremely powerful, but the more complex formulas become, the more difficult they can be to design and test.

You might need to add Automation to your solution if your formulas:

  • Use many SETF expressions to simulate flow of control (if-else, switch-case, or loops). SETF is better used for onetime setup or initialization, not for setting a state machine.
  • Depend on order of recalculation to get correct results. To provide the best performance, formulas are recalculated as needed, and the order is not guaranteed. Formulas that depend on other formulas to be recalculated first can produce inconsistent results.
  • Produce inconsistent results that don't have an obvious cause. Complex formulas might depend on side effects that could change in a future release of Visio and cause the formulas to stop working. For example, formulas should not rely on a chain of circular references to loop a specific number of times.

For a discussion of how to divide functionality between Visio formulas and Automation, see Chapter 1, Introduction to Developing Microsoft Visio Solutions. For an introduction to Automation in the Visio product, see Chapter 14, Automation and the Visio Object Model.