Only reading the FormulaU from the Ask row in Shape Data gives an exception

Started by Visisthebest, July 18, 2023, 03:29:36 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Visisthebest

I am writing some simple code to copy the entire contents of the Shape Data (Prop) section from one shape to another.

Doing it the simple way first with Shape.CellsU I am copying over all shape data FormulaUs to string variables.

But when I get to this, for instance:

Dim S as String = Shape.CellsU("Prop.MyDataRow.Ask").FormulaU

I get an exception. All the other columns (Prompt, Format, Value) no problem they are read in to string variables.

Is there something special going on with the Ask column in the shape data section?

To be sure, the invisible field also contains either Nothing, TRUE or FALSE and this converts properly in to a string, but somehow the Ask column gives an exception.

https://learn.microsoft.com/en-us/office/client-developer/visio/ask-cell-shape-data-section

Any ideas why this does not work?

Visio 2021 Professional

wapperdude

Not at my computer...
Are you using that as a literal, single line of code?  And Visio is OK with that?  Still, seems like bad form, ol' chap.

It's been sometime since I've had a need, but I thought Paul Herber's Super Utils already can do that?

Edit:  for your reading enjoyment, or insomnia cure, whichever occurs first, cell.formula discussion:  https://learn.microsoft.com/en-us/office/vba/api/visio.cell.formula
Visio 2019 Pro

Visisthebest

This needs to be integrated in to a specific add-in.

Paul's Visio Super Utilities are great but as far as I know they do not come with an API, or do they?

This is the core of the vb.net code that is creating the exception:

(I have included the Class here for clarity)


Friend Class ShapeDataRow
    Friend RowName As String
    Friend Label As String
    Friend Prompt As String
    Friend Type As String
    Friend Format As String
    Friend Value As String
    Friend SortKey As String
    Friend Invisible As String
    Friend Ask As String
    Friend LangID As String
    Friend Calendar As String
End Class

Dim SDR As New ShapeDataRow

SDR.RowName = "MyShapeData"

SDR.Ask = Shape.CellsU("Prop." & SDR.RowName & ".Ask").FormulaU


This works fine for all other Shape data row columns, but not the Ask column.

Replace ".Ask" with any other column name and the code works fine, reads in the data.

The question is why?

(Invisible column contains exactly the same type of data, yet no problem reading it)
Visio 2021 Professional


Nikolay

Because the property name is "Verify" not "Ask". The label you see in the UI and the internal name may be different:

Dim S as String = Shape.CellsU("Prop.MyDataRow.Verify").FormulaU

BTW, Pauls Herber's Super Utils does have this function out of the box (copy shape data).

Surrogate

Quote from: Nikolay on July 18, 2023, 06:22:55 PM
Because the property name is "Verify" not "Ask". The label you see in the UI and the internal name may be different
After my comment, I suddenly remembered that we had a similar topic last year. There were a few more Easter eggs hidden in the section ShapeData.
But Nikolay was quicker to respond...

Visisthebest

Thank you Nikolay that was the problem, good to know that sometimes I should expect a different internal name than what I see on the shapesheet! Don't remember running in to that problem before.

Thank you Surrogate so there are more surprises in the shape data section I understand!
Visio 2021 Professional