Visio Add-In Design to replace Application.OnTime method of Excel VBA

Started by metuemre, August 26, 2016, 09:07:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

metuemre

I need your help to design a Visio add-in. Right now I use Application.OnTime method of Excel for real time calculations but an integrated solution in Visio would be better in terms of speed and reliability.

Please find attached sample Visio and Excel files for you to see what they do.

Change the output of "DI" shape to True while Excel file is open, connectors between "DI" shape and TD_ON shapes will turn to red which means that their value is True and this value will be propogated to TD_ON shapes's Prop.IN1 value and for each TD_ON shape a counter will start in Excel file counting up to a time which is defined in Prop.TimeDelay of TD_ON blocks.

After the specified TimeDelay set point passed, Excel will make the Prop.OUT of related TD_ON shape True and connector on the right side of the TD_ON shape will turn to red. After 2 seconds related counter will disappear from the Excel since it finished its job.

You can start counters again by changing output of "DI" shape to False and True

In general, algorithm of "TD_ON" shape delays the time that the output is set to TRUE.

Do you think that it is possible to do this with a special Add-In ? End user don't need to see the counting process, so there shouldn't be a user interface for counters in the add-in. Counters will just count up to specified Timer set point and return True to the TD_ON shape's Prop.OUT which called the Add-In.

Any kind of help is appreciated.

Regards

metuemre

For those who can't open .vsdm file, please find attached .vsd version of the sample file.

I would love to hear your ideas.

Regards.

wapperdude

There have been two different methods used for timing within Visio, as presented on this forum.  The initial approach uses the Windows timer function, was first presented by Vojo.  Example of this technique can be found here:  http://visguy.com/vgforum/index.php?topic=1046.msg4590#msg4590

More recently, JuneTheSecond introduced a technique using the sleep function.  An example of this approach is here:  http://visguy.com/vgforum/index.php?topic=6519.0

These are the only two techniques that I've seen used within Visio.

Wapperdude
Visio 2019 Pro

wapperdude

Just ran across this timer related article, has some interesting info:  http://vb.mvps.org/samples/TimerObj/

Enjoy!

Wapperdude
Visio 2019 Pro

metuemre

Thanks wapperdude for the the reply. I don't think it is possible to solve this within Visio VBA. In the examples you mentioned, there is a single timer running to do things.

In my application, multiple timers running at the same time without freezing the application.

I made some research on this topic.  I guess I need a datatable with enough number of columns and rows to hold the values in the sample Excel file, multiple System.Timers and multiple System.Diagnostic.Stopwatches to do what I need in Vb.Net.

I would greatly appreciate it if you have experience with these .net classes and help me on creating a proper algorithm.

Regards

wapperdude

Afraid I have little experience with .net such things.

Regarding single timer, the reality is that everything can be triggered off a master timer, I think.  Perhaps the algorithm becomes involved, but ought to be doable.  Granted, this is a fully synchronized approach, so, one does lose that asynchronous aspect.  But, pseudo-synchronicity could be achieved by incorporating random variable increments.

The sleep function can give you "one shot" timing delays.

Just an idea.

Wapperdude
Visio 2019 Pro

wapperdude

What is it that you're trying to accomplish.  Not sure there's enough info for anyone to provide assistance...especially in the realm of algorithms.

Wapperdude
Visio 2019 Pro

metuemre

I'm trying to design an add-in to use instead of Excel.

I made some progress. Thanks to QueueMarkerEvent function, I can send required data to my add-in, do the necessary check in the add-in and send the value back to shape.

Right now it works with only one Timer. I'm trying to find a way to make it work with multiple timers.

I will post the results when it is finished.

Regards


metuemre

I give up :( It's beyond my skills to design an add-in the way I need. Running and manipulating multiple timers is really hard to do.

I will proceed with Excel unfortunately.

Thanks anyway.

Regards.

AndyW

Live life with an open mind

metuemre

Wow Andyw, this is amazing  :D I never thought that Visio was capable of doing things in real time. I saw some animation examples but they were freezing the application while running.

Let me test the code a little bit and get back to you with my questions.

Thank you so much for the help.

Regards

AndyW

Live life with an open mind

Gustavo

I know there hasn't been updates in this post recently, but I've stumbled in and it's very interesting and tons of potential. I've tried to run the sample but I'm on 64 bit Visio. I've tried to convert the code of the classes using PtrSafe on Declare Functions and LongPtr in variables where its needed, but it still not working. Then, thinking in a more basic question, it seems I can't call the User32.dll library on Office or Visio 64. Am I correct? Do you have some sample for 64 bits?

Best regards