Reputation: 4035
How can I edit Visio custom shape data from a Powershell script?
I have figured out how to open the document and how to loop the objects in a sheet, but how do I access the the shape data?
$Visio = New-Object -ComObject Visio.Application
$Doc=$Visio.Documents.Open('c:\TestVisio.vsdx')
$Page=$Doc.Pages('TestPage')
....
Upvotes: 1
Views: 1300
Reputation: 4035
Sorry, I forgot about this post. I googled for it, here is a small snippet to get you started:
$doc is your Visio file, $TabName is the name of the tab you are using.
$page=$doc.Pages("$TabName")
$ObjectName='Box1'
# Find Visio object
foreach($shape in $page.Shapes)
{
if($shape.CellExists("Prop.Row_1.Value", 0))
{
IF ($shape.Cells("Prop.Row_1.Value").FormulaU -eq "`"$ObjectName`"")
{
$NewShape = $shape
$ShapeFound = 1
break
}
}
}
Upvotes: 0