Changing Shape Names Is Confusing

M

MikeM

I put a shape on a stencil and named it "IconA." When I first dropped it on a
page, it retained that name, so I renamed it "Icon 1" using VBA
[Shapes("IconA").Name = Ex. 1"]. I later modified the stencil, renamed it
"IconA" (using Format > Special) and ran the same VBA program, but the name
of the dropped icon became "IconA.6". How can I rename "Icon" so that it
remains "Icon"?

And why does it exhibit this behavior? Why can't I reuse the name as default?

Mike
 
M

MikeM

Thanks, al. That description is very helpful. But once I drop the icon, how
do I reference it so I can change its name? I drop it using

ActivePage.Drop shpIconA 1, 1

and then the only way I know how to reference it is by noting that it's the
last shape on the page, so I use

ActivePage.Shapes(ActivePage.Shapes.Count).Name = "Ex. 1"

This seems like a very awkward way to do it. There must be an easier way.

Mike

Al Edlund said:
I'd start over here...
http://blogs.msdn.com/visio/archive/2006/07/27/679625.aspx
al

MikeM said:
I put a shape on a stencil and named it "IconA." When I first dropped it on
a
page, it retained that name, so I renamed it "Icon 1" using VBA
[Shapes("IconA").Name = Ex. 1"]. I later modified the stencil, renamed it
"IconA" (using Format > Special) and ran the same VBA program, but the
name
of the dropped icon became "IconA.6". How can I rename "Icon" so that it
remains "Icon"?

And why does it exhibit this behavior? Why can't I reuse the name as
default?

Mike
 
C

Chris Roth [MVP]

Hi Mike,

Maybe this snippet will help:


Dim mst as Visio.Master
Dim shp as Visio.Shape

Set mst = Visio.ActiveDocument.Masters( "BobTheMaster" )
set shp = Visio.ActivePage.Drop( mst, 0, 0 )

shp.NameU = "Bob"
shp.Name = "Bob"

' Note: if you name more than one shape "Bob", then you will
' *still* end up with "Bob.1", "Bob.2", etc. because shape
' names need to be unique on the page.

--
Hope this helps,

Chris Roth
Visio MVP

More Visio shapes, articles, development info and pure diagramming fun at:
www.wanderkind.com/visio


MikeM said:
Thanks, al. That description is very helpful. But once I drop the icon,
how
do I reference it so I can change its name? I drop it using

ActivePage.Drop shpIconA 1, 1

and then the only way I know how to reference it is by noting that it's
the
last shape on the page, so I use

ActivePage.Shapes(ActivePage.Shapes.Count).Name = "Ex. 1"

This seems like a very awkward way to do it. There must be an easier way.

Mike

Al Edlund said:
I'd start over here...
http://blogs.msdn.com/visio/archive/2006/07/27/679625.aspx
al

MikeM said:
I put a shape on a stencil and named it "IconA." When I first dropped it
on
a
page, it retained that name, so I renamed it "Icon 1" using VBA
[Shapes("IconA").Name = Ex. 1"]. I later modified the stencil, renamed
it
"IconA" (using Format > Special) and ran the same VBA program, but the
name
of the dropped icon became "IconA.6". How can I rename "Icon" so that
it
remains "Icon"?

And why does it exhibit this behavior? Why can't I reuse the name as
default?

Mike
 

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