Cell.Trigger method syntaxis

Started by Gustavo, January 24, 2018, 07:45:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gustavo

Hi all.

I want to run the code I have in a set of specific shape's shapesheet action cell from VBA (via the ribbon). The reason is I don't want re-write the code in VBA that I already have in the shape action cell, but I can't get the cell.trigger sintaxys right. This is the sub:

-
Sub POA_2019(control As IRibbonControl)

    Dim visSel As Visio.Selection
    Dim shp As Visio.Shape
    Dim cell As Visio.cell
    Dim cellname As String
        ActiveWindow.DeselectAll
        ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(32), visSelect  'shape selection
        cellname = "Actions.2019"  'Cell where shapesheet code is
        visSel.shp.CellsU(cellname).Trigger

End Sub



what am I missing? Any advice would be appreciated. Regards

sockmonkeyrevolt

I think the big thing is that in order to reference the action cell you need the action cell as well as the row name, so cellname should be "Actions.2019.Action" in order to trigger it. I was just playing around trying to trigger an action tweaking to a reference to a shape I had using your code just manually and I ran into problems because there aren't set statements to attach a shape to the shp object variant, but all worked when I set shp to the item after it was selected, which might be the other problem (if that was also a problem you ran into) I'm also not sure you need the visSel selection object or the Visio.Cell object either (at least not to trigger the formula in the action cell.  I got the following to work for me.


Sub messingabout()

    Dim visSel As Visio.Selection
    Dim shp As Visio.Shape   
    Dim cellname As String
        ActiveWindow.DeselectAll
        ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemFromID(11), visSelect  'shape selection
        Set shp = ActiveWindow.Selection(1)
        cellname = "Actions.Row_1.Action" 'Cell where shapesheet code is
        shp.CellsU(cellname).Trigger
End Sub

Gustavo

Thank you sockmonkey! I hadn't found many examples of the trigger method in the visio reference or the web, so I wasn't sure where the mistake was, but your code worked fine. Excellent way to avoid long translations of code from shapsheet to VBA. Best regards!