Last time we looked at creating a Visio drawing and adding a couple of objects. This time we will build on that and resize the objects and add a connector.
The Resize method on a shape is ONLY AVAIALBLE ON VISIO 2010
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 |
## create visio document
$visio = New-Object -ComObject Visio.Application $docs = $visio.Documents ## use basic template ## set active page ## Add a stencil ## Add objects $shape1 = $page.Drop($server, 2, 2) ## Resize Objects ## Connect Objects $doc.SaveAs("c:\scripts\visio\draw1.vsd") |
As seems to be the case with the other Office applications once you have worked out how to create the document the rest is relatively straightforward.
This is the same code as last time except I use the Resize method to change the size – the parameters denote the top right hand corner (values 0-7 with 0 being middle top and proceeding clockwise), the amount to drag the corner (5) and the units – in this case millimeters
The connection is made using the connectortooldataobject and defining the start and end objects.
Thanks to Alan Renouf for his powershell script to document VMware environments into Visio which forms the basis of these scripts so far.