Powershell绘制Visio容器

问题描述 投票:0回答:1

我需要使用powershell绘制visio,但我不知道powershell如何绘制容器。

这是文章https://powershellstation.com/2016/04/18/powershell-and-visio-part-6-containers/

我已经参考并遵循,但是似乎$ master尚未在某处声明,所以它失败了。

我想知道是否有人对此问题有任何说明。

这是我的代码

$Visio=New-Object -ComObject Visio.Application  
$doc=$Visio.Documents.Add(‘’)  
$Page=$Visio.ActivePage  
$stencilPath=$Visio.GetBuiltInStencilFile(2,0)
$stencil=$Visio.Documents.OpenEx($stencilPath,64)
$page=$Visio.ActivePage
$container=$page.Drop($master,5,5)
$rec=$page.DrawRectangle(2,3,5,6)
$container.ContainerProperties.AddMember($rec,1) 

这是错误

You cannot call a method on a null-valued expression.
At line:7 char:1
+ $container.ContainerProperties.AddMember($rec,1)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

我感谢大家的帮助。

powershell visio
1个回答
0
投票

这是绘制容器的代码

$stencilPath=$viso.GetBuiltInStencilFile(2,0)
$stencil=$viso.Documents.OpenEx($stencilPath,64)
$Master=$stencil.Masters('Classic')
$Page.Drop($Master,11)
© www.soinside.com 2019 - 2024. All rights reserved.