getting Shapes from Stencil

B

Brad Shook

Can anyone tell me how to get the list of shapes from a Stencil.
I have created a stencil and open it in the project but I do not want to use
VISIO. GUI I want to have my buttons on the side and when I click them
create the corosponding shape on the document.

Thanks in advance,
Brad
Here is the code I am using. It always comes back No Shapes On Page
VisApp = DirectCast(AxDrawingControl1.Window.Application,
Microsoft.Office.Interop.Visio.Application)

VisPage = DirectCast(AxDrawingControl1.Document.Pages(1),
Microsoft.Office.Interop.Visio.Page)

VisWindow = DirectCast(AxDrawingControl1.Window,
Microsoft.Office.Interop.Visio.Window)

VisDocument = DirectCast(AxDrawingControl1.Document,
Microsoft.Office.Interop.Visio.Document)

VisDocuments = DirectCast(AxDrawingControl1.Window.Application.Documents,
Microsoft.Office.Interop.Visio.Documents)

VisStencil =
VisDocuments.OpenEx(System.Windows.Forms.Application.StartupPath & "\Access
Evolution Shapes.vss",
CType(Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenRW, Int16) +
CType(Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked, Int16))

Dim vsoShapes As Microsoft.Office.Interop.Visio.Shapes

vsoShapes = VisStencil.Pages.Item(1).Shapes

Debug.WriteLine("Shapes in document: " & VisStencil.Name)

Debug.WriteLine("On page: " & VisStencil.Pages.Item(1).Name)

Dim intShapeCount As Int16 = vsoShapes.Count

If intShapeCount > 0 Then

For intCounter As Int16 = 1 To intShapeCount

Debug.WriteLine(" " & vsoShapes.Item(intCounter).Name)

Next intCounter

Else

Debug.WriteLine("No Shapes On Page")

End If
 
M

Mark Nelson [MS]

Shapes in stencils are called Masters. You need to walk the Masters
collection, not the Pages collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top