I have code that runs and imports a lot of data from Excel to Visio, adds fields, formats, etc. It all works fine but recently we decided we want to be able to hide one of the fields (the top/first field) as an option. I have tried to record a macro to record the steps of going to the Org Chart tab, then shapes, then to fields, and de-selecting the item in Block 2, which works. However, that does not seem to actually do anything when I then try to use that recorded code.
Does anyone know how to use a macro to select/hide specific data fields in a Visio Org Chart? Again, we can do it manually, but I am trying to incorporate it as an option in the larger import macro.
CodePudding user response:
As far as I know, the OrgChart Visio feature does not provide any API to interact with, i.e. does not expose any extensibility options for third-party developers to use.
From what I could imagine, you could try to modify the OrgChart's settings directly in the Visio file, either in the VSDX file itself, or using document.SolutionXmlElement
to access its settings. The settings themselves look somewhat like this:
<SolutionXML Name="SolutionModel">
<SolutionModel xmlns="http://schemas.microsoft.com/visio/2003/solutiondata">
....
<mstns:Root ID="{....}">
<mstns:Block1CustomProperty>Name,Title,Department</mstns:Block1CustomProperty>
<mstns:Block2CustomProperty>None</mstns:Block2CustomProperty>
<mstns:Block3CustomProperty>None</mstns:Block3CustomProperty>
<mstns:Block4CustomProperty>None</mstns:Block4CustomProperty>
<mstns:Block5CustomProperty>None</mstns:Block5CustomProperty>
I would have given up, though.
CodePudding user response:
Another way to interact with the addon is to use SendKeys to simulate key presses.
Here is a link to some example code: SendKeys example