VBA - Inserting Reference Triangles

D

DTran

Hello,

I'm trying to add a function in my macro that will add a reference triangle
at some X and Y coordinate. However, the only options I see are stuff like
..DrawLine, .DrawPolyline, etc. Is there a way to specifically reference the
reference triangle shape in VBA?

Cheers,
David
 
P

Paul Herber

Hello,

I'm trying to add a function in my macro that will add a reference triangle
at some X and Y coordinate. However, the only options I see are stuff like
.DrawLine, .DrawPolyline, etc. Is there a way to specifically reference the
reference triangle shape in VBA?

I don't know what you mean by a reference trinagle but you can add a
traingle as follows.

Dim stencil As Visio.Document
Dim mstShape As Visio.Master

Set stencil = ThisDocument.Application.Documents.Open("Basic
Shapes.vss")
Set mstShape = stencil.Masters("Triangle")
ThisDocument.Pages(1).Drop mstShape, 1, 1

or something like that.
You could also have used the DrawLine methods to create a triangle.
 
D

DTran

For reference triangles, they are found under the "Visio Extras" ->
"Annotations" -> "Reference triangle"

However, I understood your code to change it as follows:
Dim stencil As Visio.Document
Dim mstShape As Visio.Master

Set stencil = ThisDocument.Application.Documents.Open("Annotations.vss")
Set mstShape = stencil.Masters("Reference triangle")
ThisDocument.Application.Windows(ThisDocument.Index).Activate ' ADDED this
line
ThisDocument.Pages(1).Drop mstShape, 1, 1

However, I don't see anything on my drawing. I even reverted back to your
original code (using just a triangle from Basic Shapes) and still nothing
would appear.

Thanks for your help so far. Anymore insight?
 
P

Paul Herber

For reference triangles, they are found under the "Visio Extras" ->
"Annotations" -> "Reference triangle"

Ah yes, I was working with Visio 2003 standard at the time and that
stencil is only in pro.

However, I understood your code to change it as follows:
Dim stencil As Visio.Document
Dim mstShape As Visio.Master

Set stencil = ThisDocument.Application.Documents.Open("Annotations.vss")

Does the stencil get opened? probably not as is actually called
"ANNOT_U.VSS" or "ANNOT_M.VSS".
I've often wondered why all the stencil names are uppercase and
limited to 8 chars, DOS compatible?
 
D

DTran

I figured out my problem. It actually _WAS_ working. The thing was, I run
the macro off of another Visio Document, and it was setting it as the active
document. After confirming that by finding all the reference triangles there,
I fixed it by naming a variable called visPage and setting it as the
ActiveDocument. Then I did the visPage.Drop line.

Thanks again Paul for your time and effort.

Cheers,
David
 

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