Text Box fields

Started by domjc1962, July 15, 2017, 04:00:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

domjc1962

I have created a text box to which I have added 12 shape data fields called property1....12 of type number

I have a macro that counts all the different scenarios of certain things happening on the page.

After the macro runs I would like to change the numbers in the text box fields

The text box is sheet.49 - I can change the name later but thats what the name is currently

how do I change sheet.49.property1.value to a memory variable within macro VBA code?

I tried vispage.sheet.49.cell("Prop_row1").value = variable1

Seems textboxes dont have a master shape and when my macro goes through all shapes on vispage that textbox isnt referenced either


Yacine

It's generally a bad idea to address shapes by hard coded IDs. The IDs get lost, change, ... You have no control over it.

There are several better ways to define the shape to handle.


       
  • If it needs to be in a shape and the shape is complicated, use a master that you drop on the drawing by code. Dropping it gives you the reference to the shape.
  • Ask the user to select the shape, prior to processing it
  • Create a new shape on the fly and create the prop fields dynamically
  • Give the shape a name, then parse the shapes of the page to identify it.
  • You can also store the data in the prop section of the page or the document
  • if you master XML (I don't) you can even store XML data in the visio file
To give you neverthless a direct answer to your question:
activepage.shapes.ItemFromID(49).cells("prop.row_1").formulaU= variable1
But I recommend to not follow this option.


HTH,
Y.
Yacine

wapperdude

One more method to add to Yacine's list...

In shapesheet of your shape, i.e., sheet.49, create a User Defined entry, e.g., User.Name, and give it a name, perhaps "DataShp".  Then, in your code, initial loop thru shapes on the page to see which has User.Name = DataShp.  That avoids ID changes and or Name changes.

Wapperdude
Visio 2019 Pro