Quick start
Use Install-Module to install the latest VisioPowerShell module from the PowerShell Gallery. By setting the Scope to CurrentUser, it avoids needing administrator rights.
Install-Module Visio -Scope CurrentUser    Run the following code to launch visio and draw a shape in a new document.
Import-Module Visio
New-VisioApplication
New-VisioDocument
$basic_u = Open-VisioDocument "basic_u.vss"
$master = Get-VisioMaster "Rectangle" -Document $basic_u
$points =  New-VisioPoint 4 5
$shape = New-VisioShape -Master $master -Position $points
Set-VisioText "Hello World" -Shape $shape
Here's what's happening in that script:
New-VisioApplicationstarts VisioNew-VisioDocumentcreates a new Visio document - this document will have one page with no shapes on itOpen-VisioDocumentloads the "Basic Shapes" stencilGet-VisioMasterretrieves a the "rectangle" master from the Basic Shapes stencilThe variable
$pis defined to be geometric point built fromNew-VisioPoint 4 5New-VisioShapecreates a shape based by "dropping" the "Rectangle" master on the page at the position specified by$points- the units are always in inches. This shape will be selected once it is drawn.Set-VisioTextsets the text of the active selection - which will be the shape that was dropped in the previous step
Last updated