Updating or Creating Shape Data in Visio with PowerShell

100 Views Asked by At

I'm working on a project to create a Visio diagram via PowerShell, and I need to update an existing Shape Data (Prop.Row_1Prop.Row_3) for shapes from a stencil.

How can I do that?

1

There are 1 best solutions below

2
Surrogate On

This simple code works with shape which selected in MS Visio active window

$visio = [Runtime.Interopservices.Marshal]::GetActiveObject('Visio.Application')
$visio.Visible = $true
$doc = $visio.ActiveDocument
$shape = $visio.ActiveWindow.Selection.PrimaryItem
$shape.CellsU('FillForegnd').FormulaU = '3'
$shape.CellsU('Prop.Row_1').FormulaU = """New value1"""
$shape.CellsU('Prop.Row_2').FormulaU = """New value2"""
$shape.CellsU('Prop.Row_3').FormulaU = """New value3"""

I get this result at my side… enter image description here


I get "Unexpected end of file" on the last line.

UPD Shape based on master-shape named PC have not Prop.Row_1 - Prop.Row_3 cells by default! ShapeData Cells