Categories

PowerShell and Visio: Opening a file 2

If you run the AD diagramming script we looked at recently and save the Vision drawing on problem is that the stencil doesn’t open with it. We have to go back and add it

001
002
003
004
005
006
007
008
009
010
$visio = New-Object -ComObject Visio.Application
$doc = $visio.Documents.Open("C:\Scripts\Visio\adtest.vsd")

## set active page
$pages = $visio.ActiveDocument.Pages
$page = $pages.Item(1)

## Add a stencil
$mysten = "C:\Program Files\Microsoft Office\Office14\Visio Content\1033\ADO_M.vss"
$stencil = $visio.Documents.Add($mysten)

That enables us to start working on the document manually but can we discover the objects in the drawing?

Leave a Reply