Setting value of "D" cell

Started by perry59, February 23, 2020, 10:17:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

perry59

I have a short little macro that I hoped will add a value to the D cell of a connection point.
-------------------------------------------------------------------------------------------------------
Public Sub AddDcell()

Dim vsoShapes As Visio.Shapes
Dim vsoShape As Visio.Shape
Dim vsoCell As Visio.Cell

Set vsoShapes = Application.ActiveWindow.Page.Shapes

    For Each vsoShape In vsoShapes
         If vsoShape.CellExists("Connections.VE1", 0) Then
            'need to change rowtype first?
            vsoShape.CellsU("Connections.VE1.D").FormulaForceU = "Prop.VETerminationSignal"
        End If
    Next
End Sub
----------------------------------------------------------------------------------------------------------------
It runs without error but does not add the info to the D cell even though I see a D cell in the shapesheet (but it's empty)
so I thought maybe I need to change the row type of the connection anyway. When I attempt to do so by opening the shapesheet, right clicking the row and selecting "change row type" I get an error (see attached picture)
whats funny is, I can run the above macro which seems to do nothing, but then I can go into the shapesheet and it will then allow for changing the rowtype. I run the macro again and it puts in the value I want.
what am I missing?

vojo

there is no D cell on these types of connector points (not connection)....if there were, then the D column would be broken into 2 rows  like A,B,C.   Visio never has a cell spanning multiple rows in the shapesheet.
These connection points allow an arbitrary line to "link" to the shape

A,B define how the connection is managed (geometry rule for alignment or offset).
I usually use 0 or 5 in these cells (5 = 0 but hides the connection handle...6,7,8,9 same as 1,2,3,4 but hidden handle)
C defines the kinds of connections to be made.  essentially, line, shape, or both.  I rarely do anything with C

Plenty of doc on these cells via googling.

wapperdude

The handling of the D Cell, yes Vojo, there is a D Cell, has always been problematical.

First, to change the row type to named row, you use RowName method, not RowType.  But neither of these are successful to place a text string in the D Cell.
What I found necessary was to delete the existing unnamed row, and replace it with a named row.  This, then,  allows the text string to be added.  Example code below:

Sub Macro1()
'Rename an existing Connections row, to change it's row type.
'In order to place text in the "D" cell, the renaming row is insufficient
'The row must be deleted and replaced with a named row.
'The tag must use the "ABCD" instantiation.

'Add a connections row:
    Dim vsoShp As Visio.Shape
    Dim vsoRow1 As Visio.Row
   
    Set vsoShp = ActiveWindow.Page.Shapes.ItemFromID(2)
    intRowIndex1 = vsoShp.AddRow(visSectionConnectionPts, visRowLast, 153)
    vsoShp.CellsSRC(visSectionConnectionPts, 0, 0).RowName = "Cpt1"
   
'Delete and replace.  Note, it is not necessary to delete if named row was added initially.
    Set vsoRow1 = vsoShp.Section(visSectionConnectionPts).Row(intRowIndex1)
    If vsoShp.CellExists("Connections.Cpt1", 0) Then
        vsoShp.DeleteRow visSectionConnectionPts, intRowIndex1
        vsoShp.AddNamedRow visSectionConnectionPts, "P" & i + 1, visTagCnnctNamedABCD
    End If
       
'Add text string to "DCell"
    Set vsoRow1 = vsoShp.Section(visSectionConnectionPts).Row(intRowIndex1)
    vsoRow1.Cell(visCnnctD).FormulaU = Chr(34) & "Pin0" & Chr(34)

End Sub
Visio 2019 Pro

vojo

ok...I will bite
1)  What does this fathom D cell do (no doc on it anywhere)?
2)  I guess this applies to all connection points in the section?
3)  Since you can rename connection point, what is the intent of text string in D?

BTW, it would be great if visio ever used this cell to state the ID of what is connected!!!
   - if nothing, the "ref"
   - if something, then  "sheet.123!" or even what the other end is connected to  (cross reference between 2 shapes involved)

wapperdude

@Vojo:  it's one of those undeveloped Visio features.  Has a lot of potential, never developed/matured.  Awhile back, did a development to show both possible and shortcomings of the "D cell".  http://visguy.com/vgforum/index.php?topic=5664.msg22525#msg22525
Visio 2019 Pro

vojo

Thx...good to know

Maybe the family of setatref functions or setf function could be used by the connector to place its shape ID in the connection pt?
I don't know if something like would even work
  sheet.456!scratch.A1 = setatref(sheet.123!connector.pnt.D, setatrefexpress(<blah blah blah>setatrefvalue()<blah blah >)) 

or even the circle trick could be extended.

or nearest to path functions to identify which connection point

wapperdude

Interesting thought.  Will take a look...busy right now.
Visio 2019 Pro