Identifying Visio Stencils
In the previous posts on using Visio I’ve shown how to load and use a particular stencil. But how do you know which stencil to use?
One way is to use Windows Explorer, hover the mouse over the stencil and read the Extended File Properties. That’s a bit manual so we’ll look at producing a list of stencils and for what they are used. To do this we can’t use PowerShell directly but this is where things get real easy – we can use the scripting shell just like we did with VBScript.
Define the directory holding the Visio stencils – mine is Office 2010 on Windows 7.
Create an object for the shell and get the folder object using the Namespace method.
Jump back to PowerShell to run get-childitem on the folder using a filter of *.vss to restrict the output to stencils – always cheaper to filter at source.
We then use the Items() method of our folder to identify the file and use getdetailsof method to return the Title (Extended property number 21) of the stencil. The output is formatted using a .NET formatted string.