Author Topic: Changing shape name  (Read 3768 times)

0 Members and 1 Guest are viewing this topic.

andlop

  • Newbie
  • *
  • Posts: 7
Changing shape name
« on: May 12, 2020, 09:18:25 AM »
Hi! I know that it is possible to change a shapes name in the developer tab, but I wanted to know if it is possible to change it by adding a field in the Shape Data, and program it to do the same thing. Or it is possible to do the same thing, but using programming in the ShapeSheet.

Thank you!

Yacine

  • Hero Member
  • *****
  • Posts: 3061
Re: Changing shape name
« Reply #1 on: May 12, 2020, 11:04:49 AM »
I know it is not the answer to your question, but it is generally a bad idea to work with shape names.
Those named shapes could be deleted, moved to another page, just to name some of the problems.
You're better off by defining a certain property - eg a user or a prop field - and set its value to an arbitrary unique id (eg chosen by yourself).
To work with that shape, you would iterate over the shapes of the page and check for the existance of the property and its value.
I Hope the explanation is somewhat comprehensible.
Yacine

andlop

  • Newbie
  • *
  • Posts: 7
Re: Changing shape name
« Reply #2 on: May 14, 2020, 06:24:01 AM »
Understood, and how do I get the shape properties in the page, like its ID?

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4525
  • Ideas Visio-lized into solutions
Re: Changing shape name
« Reply #3 on: May 14, 2020, 09:02:46 AM »
The shape ID resides with the shape, not the page it's on.   You don't really want to added it to the page...That creates a lot of extra, unnecessary work.  It would be like hot gluing your socks to the drawer their in.
Visio 2019 Pro

andlop

  • Newbie
  • *
  • Posts: 7
Re: Changing shape name
« Reply #4 on: May 14, 2020, 11:04:27 AM »
But when a create a master, in the master page, the shape as one ID, but if I put that shape in a drawing I can't get the masters ID...

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3329
    • Paul Herber's website
Re: Changing shape name
« Reply #5 on: May 14, 2020, 11:27:44 AM »
Within the stencil, a master has an index, but once the master shape has been dropped on a page that index is no longer available (nor is it useful or required). The only reference from the shape on the page is to the Master name.
Electronic and Electrical engineering, business and software stencils and applications for Visio -

https://www.paulherber.co.uk/

andlop

  • Newbie
  • *
  • Posts: 7
Re: Changing shape name
« Reply #6 on: May 14, 2020, 11:38:51 AM »
I have used the command MASTERNAME() in the ShapeSheet, to get the masters name when I drop it on the drawing. The thing is, my master name is "Roller conveyor", and the MASTERNAME() output is "Roller conveyor: Roller conveyor". I'm doing a application where I needed to this two names to be the same.

Yacine

  • Hero Member
  • *****
  • Posts: 3061
Re: Changing shape name
« Reply #7 on: May 14, 2020, 01:29:22 PM »
Understood, and how do I get the shape properties in the page, like its ID?

function getMyShape() as shape

  for each shp in activepage.shapes
    if shp.cellexists("user.MyIdentificator", visexistsanywhere) then
      if shp.cells("user.MyIdentificator").resultstr("") = "I am the right shape" then
        getMyShape = shp
        exit function
    endif
  next shp

end function
Yacine