Visio Guy

Visio Discussions => Programming & Code => Topic started by: Visisthebest on May 12, 2020, 11:07:19 AM

Title: VBA-Web library for using REST APIs
Post by: Visisthebest on May 12, 2020, 11:07:19 AM
I saw this VBA library for accessing REST APIs and processing JSON on GitHub:
https://github.com/VBA-tools/VBA-Web

does anyone have any (hopefully) positive experiences with using this library in Visio VBA?

From what I can see it is actively updated.
Title: Re: VBA-Web library for using REST APIs
Post by: Nikolay on May 12, 2020, 01:16:40 PM
With almost 1500 stars on GitHub, I would be pretty sure it works :D

Visio VBA is not much different from any other VBA.

I would never do any web-calls with VBA though.
VBA is single-threaded by design, your user interface will be frozen until the request finishes.
Title: Re: VBA-Web library for using REST APIs
Post by: Visisthebest on May 12, 2020, 03:15:51 PM
Nikolay yes good point that could really undermine the user experience.
Title: Re: VBA-Web library for using REST APIs
Post by: vojo on May 12, 2020, 09:11:08 PM
I would imagine he wants to get/set shape shape data

Otherwise, I would proffer that using a REST context to draw shapes (geometries et al) would be the
perfect example of Rube Goldberg solution to a problem
("why crack a walnut with a nut cracker when you have a thermonuclear device at hand).

Note that even within visio, it takes a lot of skill to play with geometries especially if formulas involved.
Look at visio guy's constraining control handles on a circle and imagine if you used a REST context to define that.
Title: Re: VBA-Web library for using REST APIs
Post by: Visisthebest on May 13, 2020, 09:38:28 AM
It is only for getting some shape-specific data (data read from a REST API service are linked to specific shapes in a diagram linked via a unique identifier) that does not influence the shape visually other than showing some additional info in the text box or an extra text label, no writing data back via REST.

I assume it is possible to show a progress dialog window with a cancel button for the user to abort importing data from a REST API if it takes too long, it is a read-only scenario so much simpler than doing updates and having to verify if updates were done completely and correctly.
Title: Re: VBA-Web library for using REST APIs
Post by: Nikolay on May 13, 2020, 09:45:11 AM
Quote from: Visisthebest on May 13, 2020, 09:38:28 AM
It is only for getting some shape-specific data (data read from a REST API service are linked to specific shapes in a diagram linked via a unique identifier) that does not influence the shape visually other than showing some additional info in the text box or an extra text label, no writing data back via REST.

I assume it is possible to show a progress dialog window with a cancel button for the user to abort importing data from a REST API if it takes too long, it is a read-only scenario so much simpler than doing updates and having to verify if updates were done completely and correctly.

It is not possible to do that (the progress dialog with cancel button). This is what "single - threaded" means, if translated to user language :D
Title: Re: VBA-Web library for using REST APIs
Post by: Nikolay on May 13, 2020, 11:40:07 AM
BTW, regarding the REST, I would try to use the built-in Visio "Connect to Data" maybe?
There are some "connectors" out there you could use to "convert" a REST API into a standard ODBC "database-like" data source that can be consumed by the Visio.

Here is one for example:
https://www.cdata.com/kb/tech/rest-odbc-visio.rst

Here is another:
https://www.progress.com/tutorials/odbc/query-any-rest-api-using-odbc-in-5-mins---getting-started-(part-1)

No code. All built-in.
Title: Re: VBA-Web library for using REST APIs
Post by: Visisthebest on May 13, 2020, 01:52:39 PM
Thank you Nikolay I didn't know this solution existed will check it out!