Is this embedded VBA?

Started by analogman, March 11, 2020, 06:20:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

analogman

I'm trying to understand what the formula shown below is doing. Microsoft states that the parameter to RUNADDON is: "The name of an add-on in the Addons collection or a macro in a VBA project." However, this is neither.

In this case, the parameter being passed to RUNADDON is a string. My thought is that it consists of lines of VBA code but I do not understand how to break it up into its pieces.

A couple questions I have are:
1. Do the colon characters separate lines of code?
2. Is the "Set C=ActiveWindow..." declaring and setting a variable named C to ...Items(5).Characters which is then used in the lines of code following it?

I can't seem to find much information online and any help is appreciated.

BTW: I do have software exprience, C, C++ and C# mostly, but not VB.

=RUNADDON("Set C=ActiveWindow.Selection.item(1).Shapes.Item(5).Characters:N=C.CharCount:C.End=InStr(C.Text,""»""):C.CharProps(2)=0:C.Begin=C.End:C.End=N:C.CharProps(2)=1:C.Begin=InStr(C.Text,""{"")-1:If C.Begin<>0 Then C.CharProps(2)=0")+DEPENDSON(User.F)

Nikolay

#1
1. Yes
2. Yes

By the way DEPENDSON() causes the expression (statement) to be executed (re-evaluated) when User.F cell changes.

In general, I would say this whole thing looks like some crazy programming practice to avoid ;D

From the looks of it, it highlights some piece of text of some sub-shape text bold (and red?) when some conditions are met.
I'd look at Characters.CharProps(x) in the docs.

analogman

Thanks Nikolay. Seems like I'm on the right track.

I think I'm finding a lot of fluff in this stencil that someone added while developing the shapes and they never bothered to clean it up. (You know how it is looking at someone else's code  :-[)

I'll have to go see what that User.F cell is about. Probably something not used.

I have been a user of this stencil for a couple years now but never had to look at the internals. I took on responsibility of updating it and so now I have to dig in. I've never seen any text getting highlighted, changing color or being made bold in any of the shapes when I used them. There's no reason for that kind of functionality for what we uses these shapes for. So I'm hoping that's all this is.

Many thanks again!

Visio Guy

Does the code in RUNADDON actually work? I'm pretty sure they turned off in-cell VBA years ago, because it was such a ripe place for document viruses.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Paul Herber

RUNADDON with VBA code was turned off many years ago. Visio 2002 by the looks of it.
https://docs.microsoft.com/en-us/office/client-developer/visio/runaddon-function
Electronic and Electrical engineering, business and software stencils for Visio -

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

analogman

QuoteDoes the code in RUNADDON actually work?
Good question. I don't know how to run it. It is in a User.Format cell and peeking at User.Formula in the Formula Tracing window, there aren't any references to it. Does that mean it's dead code? Or could it be referenced from somewhere else that doesn't show in the Formula Tracing window?

Nikolay

#6
I think you could be pretty safe simply removing this code. I also have not seen anything except add-on name in the RUNADDON... but I may be just too young.

Even according to the above official article (by Paul), this code is not working for the past 20 years.
Even if you find Visio 2000, or Visio 5 to run this code, you will be able to run it only on Windows XP machine (or Windows 98 for Visio 5?).

If you are really keen to make that code work, you would need to have a VM probably with Windows XP, then install Visio 2000 there, then open that file;
then the code may run and paint 5-th sub-shape of some shape with text that contains "}" and "»" in it with bold red.
If you modify the "F" cell in the user section, of course.

Can you share the drawing? Maybe we'll find someone obsessed enough to do it actually, taking into account home-offices thing :D