Visio Guy

Visio Discussions => Programming & Code => Topic started by: domjc1962 on July 15, 2017, 04:00:15 PM

Title: Text Box fields
Post by: domjc1962 on July 15, 2017, 04:00:15 PM
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

Title: Re: Text Box fields
Post by: Yacine on July 15, 2017, 10:37:30 PM
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.

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.
Title: Re: Text Box fields
Post by: wapperdude on July 16, 2017, 12:04:51 AM
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