ThisDocument Exit Textbox Event

Started by OldSchool1948, February 12, 2021, 06:42:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

OldSchool1948

My application shows a Project Name and System Acronym at the top of every page (up to 30 pages).  Both of those data elements are textbox objects on a "Project Info" page.  When either is changed, I need to apply the update to every page.

Since Visio has no textbox loose focus or Exit event, I resorted to using two global variables that I set when Visio opens. I compare the global variables against the text boxes in the BeforeTurnToPage event and run a macro if the values don't match. This works provided the user moves to another page.

Clearly, I need a better solution. I tried the Changed event, but it fires for every keystroke. I toyed with the idea of somehow using a PageSheet user-defined row to trigger/run the CALLTHIS function.  But I can't figure out how to detect when the cursor moves from a textbox on a page.

Unfortunately, my client won't let me put those (and about 50 other textboxes) on a multi-tab form for data entry, which would solve my problem.  Any suggestions would be greatly appreciated. 

Thomas Winkel

Not sure if I understand correct.
But I think this is possible without code, only shape data and shapesheet formulas.
See attached document.

If this is not what you need, please provide an example.

Paul Herber

There is nothing special about text boxes, they are just rectangles with no border line.
I think the only way to do what you want is to look at the selection changed event.
Electronic and Electrical engineering, business and software stencils for Visio -

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

OldSchool1948

Hi Thomas,

Your example is exactly what I am trying to do, when it comes to updating the "other" pages.  But, I'm using textboxes and not shapes to store the Project Name and System Acronym.  I love the idea of using Shape Sheet formulas to store the Value of each textbox in the Document Sheet; I cannot figure out how to do that using a textbox's Value property as opposed to a Prop section row using Setf(Getref()).

Regards,

Johnnie

P.S.  Thank you for your help.  Your use of Setf(Getref()) has given me some ideas on how to use those functions in some other areas.  Much appreciated!

Thomas Winkel

Hi,

I think you was on the right path.
See attached document.
I just had to complete the Change() event.

You can edit the Document ShapeSheet in Ribbon -> Developer -> Show ShapeSheet -> Document


wapperdude

Little late to the party, why not put your text boxes on a background page?  Every drawing page can reference the background.  Everything will have same info in the same location, no VBA needed. No stylesheet editing needed.
Visio 2019 Pro

OldSchool1948

Using a background page for the Project name would work, and I may do that.  Thanks!

I have a similar shape that holds "location" information (vnet, subnet, or site) on certain pages where a background page won't work.  My app is an electronic system design document that captures application, system, or service location specific design and engineering information for commissioning and decommissioning servers in Cloud only, On-Prem only, and/or Hybrid-Cloud environments.  Because of the variations, using the Shape Data for location is a little trickier.  Thomas' help has pointed me in the right direction. 

Unlike Project name and System Acronym, location won't change unless the network architecture changes.  Using Shape Data for real time updates is far better than having to loop through pages to make changes.  In this case, I will use the Page Sheet as it already has all of the location metadata I need.

wapperdude

Just for same of completeness, background pages may be cascaded.

For example, all drawing pages may have same header.  That could be on a background page, named bkgnd-Hdr.  But pages 1 - 3 have a common description, perhaps DC Pwr.  But no other pages have that description.  You could make a bkgnd page, name it, say, bkgnd-DC.  Then, set that page to have its background set to bkgnd-Hdr. Pages 1-3 would have their backgnd set to bkgnd-DC.   This way, pages 1 - 3 show info from both background pages. 

The remaining drawing pages can have different combinations.

Not saying this is best solution, just indicating there's flexibility available with background pages.

Visio 2019 Pro

OldSchool1948

wapperdude.  This is good information. 

I have six background pages.  Three for page size 17x11 and three for page size 34x22 based on page type (Cover page, Info page, or App/Sys Design page).  Some have a legend and some do not.  The Cover page has unique security markings, all other pages share the same markings.  Using your approach, I could have reduced it to four.