Extracting text from all shapes in a layer

Started by TUlm, May 26, 2010, 06:56:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jumpy

OK, in this case you cannot use the Shapes ID, because after deleting a shape it can be reassigned by Visio to another new shape.
Also I understand you so, that more than one shape can have the same ID (if they have the same text??).
But what if you alter the text? Then the shape will still have the same ID (because it must not be altered) but a now different text???

One idea to assign IDs could be to store the current "maximumID" in a user defined cell of the page. Now if a new shape comes into play and is worthy of a new ID your code can lookup the maxID in the page, increase it by 1 or a random number, save it again in the page and then assign it to the shape.

TUlm

Couldn't i just write some event driven code that changed the ID value back to the default value when a user changed the text within the shape?

Jumpy

Why should the ID value change  if you change the text (in the first place)?
I think I still don't gasp the connection between text and ID of a shape.

Maybe Yacine is smarter then me and has an idea?

TUlm

For this project the ID value is associated with the text in the box. Each string has an ID number, all strings that are the same have the same ID number. If you have multiple strings that are the same and have the same ID number and change just one, its ID needs to change so that it isn't the same as the other strings that it used to be the same as. Does that make more sense?

wapperdude

Sorry if I may have missed some of the details in the previous replies to this post...

... but, mucking with the shape ID strikes me as a bad idea.  Why not just add a custom property that contains the "shape ID"?  I think it'll be more controllable and predictable to use custom properties rather than mess with shape ID.  In fact, unless you want to control visibility, I'd avoid the layers to. 

All of this could be done in the shapesheet, extract report, and then filtered in Excel.

In fact, via shapesheet, you could enter your single line of text, the "sf..........." (whatever), and parse it using shapesheet functions as long as the format is defined and constrained.

Wapperdude
Visio 2019 Pro

Jumpy

When talking about ID I was thinking like you Wapperdude of a ShapeData or user defined cell, where a somehow selfgenerated ID is stored to identify or classify certain (types of) shapes, because messing with the Visio Shape ID is a bad idea. I don't even now, if it is possible.

Yacine

#21
Hi Tulm,
sorry for my long silence.

What you are doing with the layer is selecting shapes that have not got yet any user defined data, nor shape "smartness". In case of bigger diagrams, where it does not make sense to replace shapes by hand, I do it the same way. It is basically only a better way of selecting a certain number of shapes.
If your are anyway on the VBA path and you have no other way to identify your shapes, stay with that method.
(You got already the code from the forum)

Now the ID stuff. Could it be that there is a misunderstanding here? As ID, most people understand a unique identification number, which you don't want as it is only a coupling of a "string" property field with numbers.

Now you join the two ideas by transforming the shapes belonging to that specific layer and giving them the properties you need. (Ask if you don't know how to add custom props by code).
now let your user (yourself?) set the props from a fixed list. done.

Please don't misunderstand my tone, I am sort of thinking loudly.

An example of this thought applicated to your problem... will follow... cheers
Yacine

TUlm

Im sorry i dont think i was entirely clear. When i was referring to an ID number i just meant a unique string of text that is paired with a text string inside a shape. It can be hidden in the shapesheet. Also, i do need to know how to add custom properties by code if you can either give me a brief example or link me to one.

Yacine

Yacine

wapperdude

You might also consider using the index and lookup functions in the shapesheet.  See "Functions", at http://msdn.microsoft.com/en-us/library/ms427031.aspx.   

VisioGuy has at least one practical example, Choose Colors with Shape Data Fields, http://www.visguy.com/2009/10/21/choose-colors-with-shape-data-fields/.  Seems I recall he had additional info, but, I can't find the missing memory cell in my head.  (If I could, it wouldn't be missing!)

HTH
Wapperdude
Visio 2019 Pro