Visio Guy

Visio Discussions => Programming & Code => Topic started by: AndyMacrae on February 01, 2023, 06:55:12 PM

Title: Calling actual Visio Dialogs from VBA\running code after a Visio Data Refresh
Post by: AndyMacrae on February 01, 2023, 06:55:12 PM
Hi,  I have custom code that changes the color of workstation objects depending on their reserved status, which it reads from an external data source.  What I need to do is have my "coloring code" run whenever the standard Data --> Refresh Data dialog is run from Visio at start up.  Is there some way to have my code trigger after this dialog is run?
Title: Re: Calling actual Visio Dialogs from VBA\running code after a Visio Data Refresh
Post by: Yacine on February 02, 2023, 07:09:40 AM
I wouldn't know of an event fired automatically after data refresh, but you write "at start up". Do you use the document_opened event? Then add to your already existing call for data refresh, a call to your coloring macro.


Secondly, it sounds weird to use a macro to color shapes. That's what smartshapes are for. Ie: you can set the color by means of formulas depending on values of the custom data.
Title: Re: Calling actual Visio Dialogs from VBA\running code after a Visio Data Refresh
Post by: Nikolay on February 02, 2023, 10:20:31 AM
Why, there seem to be an explicit event for this, Application.DataRecordsetChanged:

https://learn.microsoft.com/en-us/office/vba/api/visio.application.datarecordsetchanged
Title: Re: Calling actual Visio Dialogs from VBA\running code after a Visio Data Refresh
Post by: AndyMacrae on February 09, 2023, 03:10:24 PM
Thank you everyone.  I will give these suggestions a try!