Author Topic: Triggering an Action cell  (Read 722 times)

0 Members and 1 Guest are viewing this topic.

Visisthebest

  • Hero Member
  • *****
  • Posts: 637
Triggering an Action cell
« on: March 27, 2022, 09:12:58 AM »
Is it possible to trigger an Action Cell with a shapesheet function? I can use Cell.Trigger in VBA but a shapesheet solution would be better in this case.

In this particular use case, DEPENDSON (the other way around) cannot solve the issue elegantly because of the very particular way and order in which I want cells to be triggered. Also DEPENDSON() does not work in the Action cell in the Actions section.

I want to make use of action cells without a menu entry ("") to solve a particular challenge, inspired by this article:

https://visualsignals.typepad.co.uk/vislog/2018/03/action-cell-execution-in-visio.html

Great if this is possible!
« Last Edit: March 27, 2022, 09:41:09 AM by Visisthebest »
Visio 2021 Professional

Yacine

  • Hero Member
  • *****
  • Posts: 2953
Re: Triggering an Action cell
« Reply #1 on: March 28, 2022, 12:57:40 AM »
Why does dependson not work in your case?
Yacine

Croc

  • Sr. Member
  • ****
  • Posts: 311
    • Visioport
Re: Triggering an Action cell
« Reply #2 on: March 28, 2022, 02:00:21 AM »
In the article mentioned above, John uses the EVALCELL function for this purpose. Why is this method not suitable for you?
For example EventXFMod = EVALCELL(GetRef(Actions.Row_1.Action))
Quote
Also DEPENDSON() does not work in the Action cell in the Actions section.
You can use an intermediate cell. For example Scratch.
Add to Action cell +Setf(GetRef(Scratch...),Scratch...+1)
Then DEPENDSON(Scratch...)
« Last Edit: March 28, 2022, 02:12:22 AM by Croc »

Yacine

  • Hero Member
  • *****
  • Posts: 2953
Re: Triggering an Action cell
« Reply #3 on: March 28, 2022, 04:13:30 AM »
In the article mentioned above, John uses the EVALCELL function for this purpose. Why is this method not suitable for you?
For example EventXFMod = EVALCELL(GetRef(Actions.Row_1.Action))
Quote
Also DEPENDSON() does not work in the Action cell in the Actions section.
You can use an intermediate cell. For example Scratch.
Add to Action cell +Setf(GetRef(Scratch...),Scratch...+1)
Then DEPENDSON(Scratch...)


The intermediate cell would also be my approach. You don't need the action command to actually be in the action section.
« Last Edit: March 28, 2022, 04:16:53 AM by Yacine »
Yacine

Visisthebest

  • Hero Member
  • *****
  • Posts: 637
Re: Triggering an Action cell
« Reply #4 on: March 28, 2022, 04:39:04 AM »
Croc, Yacine thank you the solution with an intermediate cell will probably work for this I will try to use it!
Visio 2021 Professional

Visisthebest

  • Hero Member
  • *****
  • Posts: 637
Re: Triggering an Action cell
« Reply #5 on: March 29, 2022, 05:16:49 AM »
Using an intermediate cell in the Action section and using EvalCell() to trigger the intermediate cell solves my problem perfectly!

It provides me exactly the control I need to have the specific cell(s) only fire when I want them to.

Pretty useful those 'hidden' (menu text empty "") action cells for specific use cases, thank you everyone for your input!
Visio 2021 Professional

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4374
  • Ideas Visio-lized into solutions
Re: Triggering an Action cell
« Reply #6 on: March 29, 2022, 07:29:00 PM »
Can you share example?  Someone might have a need in the future.
Visio 2019 Pro

Visisthebest

  • Hero Member
  • *****
  • Posts: 637
Re: Triggering an Action cell
« Reply #7 on: March 30, 2022, 04:02:07 AM »
Please find attached the example Wapperdude.

I am using this example to demonstrate how using action cells solve a key issue.

Because I use a Visio add-in (written in VB.NET in preparation for the AMAZING TwinBasic.com!), for this example you need to turn on Visio Event Viewer to see what is going on.

Use case:

1. I use a lot of code for (automatically) adding and changing shapes, which means in some cases when I fire a MarkerEvent (with QUEUEMARKEREVENT on the shapesheet), the shape selection has moved on and I am not sure if the shape in the selection is actually the shape that fired off the event! (leading to errors).

2. That is why I want to add the string from the shape ID() function to the string that QUEUEMARKEREVENT adds to the event, to make sure I identify the right shape that has fired the event.

(I now also have a way of making sure I get the right page and document the shape is on, to be absolutely sure I know which shape fired the event, but is beyond this example -> I think making absolutely sure which shape fired the MarkerEvent is critical for software reliability, but I may be overly cautious)

3. But for firing off MarkerEvents when shape data changes, if I create a QUEUEMARKEREVENT + DEPENDSON in a user cell, and it contains an ID() field, the MarkerEvent also fires if you drop the shape on the stencil. There may be more than 10 of such cells in the shape, meaning a shape drop results in many markerevents firing that shouldn't.

4. By putting the QUEUEMARKEREVENT in an Action cell (with no menu string "" so invisible to the user), then firing this cell with EVALCELL() + DEPENDSON() in a user cell, I do get MarkerEvents when users change shape data, but not when the shape is dropped from a stencil!

I hope the example file is clear:

- There are three identical shapes on the shapesheet. When you double-click on any of them, you get the Shape Data with the ColorSetting dropdown.
- Change the color and press ok, and you will see in Visio Event Viewer that the MarkerEvent has fired from that shape ID and what the color setting is now
- If you drop any of these shapes in a stencil, then drop them back on to the page, you will see MarkerEvent does not fire and my problem is solved with this solution!

So John Goldsmith's article (and the feedback in this forum) has really solved a tough issue for me, thank you!

https://visualsignals.typepad.co.uk/vislog/2018/03/action-cell-execution-in-visio.html
Visio 2021 Professional

Yacine

  • Hero Member
  • *****
  • Posts: 2953
Re: Triggering an Action cell
« Reply #8 on: March 30, 2022, 05:37:43 AM »
... a Visio add-in (written in VB.NET in preparation for the AMAZING TwinBasic.com!), ...

? ? ?
I am curious about it.
Any pre-premiere?
Yacine

Visisthebest

  • Hero Member
  • *****
  • Posts: 637
Re: Triggering an Action cell
« Reply #9 on: March 30, 2022, 05:46:07 AM »
Developing an add-in for a customer currently can’t say too much about it much of the design is based on their intellectual property, but once ready I intend to make a separate Visio add-in with some diagram reporting functionality that Visio doesn’t offer.

I looked at Shape Reports:

https://support.microsoft.com/en-us/office/create-a-report-of-shape-data-d277cef5-0613-42ad-8738-4d07954d3e93

but for sure they don’t cover the diagram reporting requirements I need to cover.

Will be a free add-in to do my little part in advancing the Visio desktop ecosystem.

TwinBasic is also advancing for Visio add-in development:

https://twinbasic.com

when it is released, because it works directly on COM without the slow .NET interop, will allow for lightning fast Visio add-ins! I would guess their version one release is Q4 this year.
Visio 2021 Professional

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3281
    • Paul Herber's website
Re: Triggering an Action cell
« Reply #10 on: March 30, 2022, 05:53:07 AM »
Whatever shape triggered the event, if you know the shape then you can get the shape's containing page. You don't need the page id.
Electronic and Electrical engineering, business and software stencils and applications for Visio -

https://www.paulherber.co.uk/

Visisthebest

  • Hero Member
  • *****
  • Posts: 637
Re: Triggering an Action cell
« Reply #11 on: March 30, 2022, 06:29:56 AM »
Paul you are right if I get the shape from the selection, but in this case I get the Shape ID from the ID() shapesheet function, so the code in the add-in processing the markerevent doesn't get a shape object just a shape ID number (that could have come from another page, even in another document that is open at the same time, as the shape ID's are only unique per page).

The way I process marker events does require more work than just getting the shape from the selection for sure.

I would love it if there would be a CALLTHIS() for add-ins in Visio 2023/2024, so I get the Shape object reference as an argument in the call to a sub/function in my add-in.

I do not know how to know for sure which shape fired off the QUEUEMARKEREVENT shapesheet function, or more precisely: in which shape did the cell fire that created the markerevent the add-in is now processing.

That's why I've created an elaborate alternative solution, which also requires that the Document and the Page have respectively a User.DocID and User.PageID row that I initialize with the ID's of the respective document and page before any other code runs. I add all this information to the string that QUEUEMARKEREVENT provides as an 'argument' so that my code is absolutely sure where the markerevent came from.
« Last Edit: March 30, 2022, 06:36:36 AM by Visisthebest »
Visio 2021 Professional