Powershell绘制visio容器
Powershell draw visio container
需要用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
感谢大家的帮助。
这是绘制容器的代码
$stencilPath=$viso.GetBuiltInStencilFile(2,0)
$stencil=$viso.Documents.OpenEx($stencilPath,64)
$Master=$stencil.Masters('Classic')
$Page.Drop($Master,11)
需要用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
感谢大家的帮助。
这是绘制容器的代码
$stencilPath=$viso.GetBuiltInStencilFile(2,0)
$stencil=$viso.Documents.OpenEx($stencilPath,64)
$Master=$stencil.Masters('Classic')
$Page.Drop($Master,11)