我正在尝试在开关形状和服务器形状之间更改Visio中连接器的颜色。我目前的代码如下:
$From = $svrSwitch.MachName
$To = $SvrSwitch.Switch
$ConnFrom = $page.Shapes | Where {$_.name -eq $From}
$ConnTo = $page.Shapes | Where {$_.name -eq $To}
$ConnFrom.AutoConnect($ConnTo, 0, $connectorSwitch)
$arrow = $page.Shapes | Where {$_.name -eq "Dynamic Connector"} | select -First 1
$arrow.NameU = "$From-TO-$To"
$arrow.fill.ForegroundColor = 0xff0000
当然我理解最后一行不正确,我只是不确定如何继续。
非常感谢你的帮助。
答案 0 :(得分:0)
要理解的是,您要在形状的ShapeSheet中写入单元格,因此其中任何一个都应该有效:
$arrow.CellsU("LineColor").FormulaU = "=RGB(30, 200, 30)"
$arrow.CellsU("LineColor").FormulaU = "=THEMEVAL(""AccentColor2"")"
这是一个基于Visio 2013的完整示例(无错误处理):
$application = New-Object -ComObject Visio.Application
$documents = $application.Documents
$document = $documents.Add("NETWME_M.VSTX")
$page = $document.Pages(1)
$stencil = $application.Documents("PERIME_M.VSSX")
$switchMst = $stencil.Masters.Item("Switch")
$serverMst = $stencil.Masters.Item("Server")
$switchShp = $page.Drop($switchMst, 1, 4)
$serverShp = $page.Drop($serverMst, 3, 4)
$visAutoConnectDirNone = 0
$switchShp.Autoconnect($serverShp, $visAutoConnectDirNone)
$dynConnShp = $page.Shapes($page.Shapes.Count)
# $dynConnShp.CellsU("LineColor").FormulaU = "=RGB(30, 200, 30)"
$dynConnShp.CellsU("LineColor").FormulaU = "=THEMEVAL(""AccentColor2"")"
如果你不熟悉ShapeSheet,那么你可能会发现这个介绍很有用:
http://visualsignals.typepad.co.uk/vislog/2007/10/just-for-starte.html