Friday, April 19, 2013

VISIO: automating find and replace

We have several environment that are structurally the same, and they differ only for some configuration values.
Maintaining a separate VISIO diagram for each of them is a nightmare.
One should have a template and populate it dynamically.
Linking shapes to a Datasource is an option, but it seems quite complicated to me.
I have tried exporting to XML (.vdx file), changing the XML with a find/replace, and reimporting, but VISIO fails to import the modified file :
The shape contains a text property row element that is not referenced from the shape's text. Visio has ignored the element

Finally I found that exporting to SVG file, doing the Find&Replace and importing again works pretty well. The only caveat is that VISIO tends to break text in multiple separate tags, so you should avoid defining labels like ${domainNumber} or even ___domainNumber; I chose for labels the format zzzdomainNumber.

I am using VISIO 2007. Maybe in VISIO 2010 the XML is less touchy.

No comments: