2

I am using Visio Professional 2021 and VS 2019 for my development.

I want to add data graphics to my added shape in Visio as per the below screenshot. Can you suggest some possibilities in C#?

Below is my code which I have tried to

enter image description here

short customProps = (short)VisSectionIndices.visSectionProp;

short rowNumber = shape.AddRow(customProps, (short)VisRowIndices.visRowLast, (short)VisRowTags.visTagDefault);

shape.CellsSRC[customProps, rowNumber, (short)VisCellIndices.visCustPropsLabel].FormulaU = "\"" + PropertyName + "\"";

shape.CellsSRC[customProps, rowNumber, (short)VisCellIndices.visCustPropsValue].FormulaU = "\"" + propertyValue + "\"";

But i want to add data graphics on each shape as per the shown image.

  • 1
    Hope [this article](https://learn.microsoft.com/en-us/office/vba/visio/Concepts/about-displaying-data-graphically-visio) with VBA code can helps – Surrogate Oct 12 '22 at 09:50
  • i have gone through the documents but my doubt is how i can create Data Graphics Item using c#/vba code ? – Nihar Sahoo Oct 12 '22 at 10:31
  • Did you read article [Assembling data graphics programmatically](https://github.com/MicrosoftDocs/VBA-Docs/blob/main/visio/Concepts/about-displaying-data-graphically-visio.md#assembling-data-graphics-programmatically) ? Also you can download [SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6d637611-cdf5-49da-b5c3-0f34719008a9), there you can find module cs_CustomiseDataGraphics – Surrogate Oct 12 '22 at 18:31

1 Answers1

0

In Visio user interface they are called: Data Graphics

In object model code they are called: GraphicItems

https://learn.microsoft.com/en-us/office/vba/api/visio.graphicitems

In the article you will find:

*Note You must create masters of type visTypeDataGraphic by using the Visio user interface—you cannot create them programmatically.

and

The AddCopy method adds a copy of an existing GraphicItem object to the GraphicItems collection. The GraphicItem object to be added must already exist in another master of type visTypeDataGraphic.

https://learn.microsoft.com/en-us/office/vba/api/visio.graphicitems.addcopy

Dennis
  • 41
  • 5