Control link data to shape mapping with VBA

Started by rnicolle, June 26, 2012, 09:56:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rnicolle

Hi,

I wanted to know if you could, using VBA code, link data to shape from Excel, displaying all the columns in Visio (so select all the columns when asked in the link data to shape wizard), but not linking all the columns in the shape.

For instance, in buisness flowcharting : we have an Excel file with data, and a column "Type", which indicates if we are dealing with a process shape, a decision shape, a start/end shape or a sub-process shape.

This information is here only to allow the user to know on which kind of shape he will link the data (so it should be displayed on Visio), but we don't want this column "Type" to appear in the shape data.

Is there a way in VBA to do that ?

Let me know if my explanations aren't clear,

Thanks in advance

aledlund

When Visio links a datarecord to a shape it copies all of the columns to the shape. If a shapedata field exists with the same name as a datacolumn it will apply the datarecord to it, if a shapedata field does not exist it will create a new shapedata field with a (modified) name based on the new field. The new field should not display in the shape data dialog. So as long as you don't have a field name of "type" then the "type" column should not show in the shape dialog.

al

rnicolle

Al, thanks for your answer.

I know the general behavior when linking data, but when we don't have the shape data corresponding to the Excel column, the shape data is created, but visible in the shape data window, so I don't have the behavior that you describe (or I misunderstood what you said).

I have a workaround which is to add shape data with the same name than the column in Excel, and to set it to hidden. So it is linked, but it remains invisible for the user.

My goal is to find a proper way to do that, without even linking some columns to shape data, but still displaying them in the external data window in Visio.

So you are saying that this is not possible with VBA ?

Raphaƫl

aledlund

My apologies, it appears that things have changed. When a column is added that does not have shape data already the name has '_VisDM_' appended to the front of the name. The first underscore at one time was a signal to Visio not to display the field. It looks like that has changed in v2010. It also appears that changing the Invisible field from 'NoFormula' to 'TRUE' does not inhibit it from showing up in the ShapeData dialog (where changing one of the prebuilt ones does inhibit it). I'd go with your workaround.
al

Jumpy

What may be possible in VBA is to go through the shapes after the linking and change the visibility of the unwanted columns (columns in excel and external DataWindow that is - rows in the SHapeSheet).

aledlund

I went directly into the shapesheet for the inserted shapedata (_VisDM_) rows and changed them, they stll show up. The point of interest is that the row names shown in the ShapeData dialog are the correct names, not the modified names. That would indicate that Visio is operating against them and is probably ignoring the change to the 'Invisible' cell.
:(
al

Jumpy

Maybe the underscore in the name has still some meaning for Visio?