Accessing the Columns, Rows and Cells of a Grid shape

Started by Brizky, January 18, 2018, 06:27:26 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Brizky

Hello, folks.

I'm using the Grid shape to create a table of information.  All I need to do is add some text to every cell in each row of my table.

I'm still trying to understand how Visio works programmatically.  I've managed to figure out how to create a Grid shape using the "chart_u.vssx" shape template.  But I have no idea how to access the columns, cells and rows of the Grid. All I can do is simply draw a GRID with a specific number of rows and columns.

I attempted to record a macro while I made some changes to certain cells.  Then I looked at the code.  But Visio inherently knows all of the IDs for the cells, so it just references the cells by ID.

I need to be able to draw my GRID shape.  And then, using the shape as a reference, access the specific rows, columns and cells of the grid so that I can stick my information in them.  I'm thinking it should be a simple iteration through the rows and columns.  But I just don't know how to get to them.

I'm still trying to wrap my head around accessing shape cells and using formulas to do simple things like change the color of text for a shape and the like.  So figuring out how to get to the cells of a GRID shape is really giving me a run for my money.

Thanks for reading,

Brizk

Surrogate


Brizky

Right, I can create a shape called "Grid".  It comes from the calling:

chartingStencil = Application.Documents.Add("chart_u.vssx"). 

And from that document, the Grid shape can be gotten:

TheGridShape = chartingStencil.Masters.Item("Grid")

Then I can just drop TheGridShape on my page. 

I was hoping there would be something like MyGridShape.rows(1).columns(2).text type of thing.  But I've been messing around with Visio programmatically for about a month now.  And getting things to happen isn't that nice and neat.

Surrogate

#3
About 5 years ago I shared same macro in that thread: Specification: transferring data from Excel and Visio back (translated via Microsoft Translator).
you can find there two files for download, which contain macro for same purpose.