• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • Visio Shape Report Converter
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Using Visio in Education for GIS
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articlesâž¡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts âž¡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Booksâž¡
      • Visualize Complex Processes with Microsoft Visio
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network
You are here: Home / Shape Design / ShapeSheet Formulas / Highlighting dirty text in Visio shapes

Published on June 23, 2023 by David Parker

Highlighting dirty text in Visio shapes

I suppose I should explain what I mean by dirty text first 🙂

I often display the value of a Shape Data row in Visio text, but sometimes the solution requires that the value is also editable. This is ok if the client accepts that all editing is done with the Shape Data window or dialog, but not if the user more naturally wants to edit the text in the shape. In my current solution, I want to pass the manually edited text to another process for checking, and then only update the Shape Data row when validated or accepted, before re-setting the text with the inserted field. My first task was to spot with text had been manually overtyped, so I decided that checking the value of a new User-defined Cell, called IsDirty, was best, and then this value can be used to change the color of the text (or it could be the LineColor or FillForegnd) to make this value visible.

When Insert / Field is used in Visio, it creates a Text Fields section which can hold the reference to the inserted field.

If the text is manually overtyped, then the rows in the Text Fields section get deleted.

  • The Prop.Name Shape Data row inserted as a Field
  • Editing the Shape Data window dislays the value in the shape too
  • Editing the text deletes the inserted field

So, I wanted to highlight when this has happened so it can be handled in code.

First, I added a User.IsDirty row with the formula:

=ISERR(Fields.Value)

This returns False when the Fields.Value cell exists, returns True if it does not. Unfortunately, the User.IsDirty formula is automatically reset to ISERR(REF()) when the text is overtyped because the cell that it referred to is now deleted.

  • Add User.IsDirty to return False if inserted field
  • User.IsDirty return False when text is edited

So, the next issue is to display this change in the UI, so I edited the Character.Color formula to change from Black to Red if IsDirty = True:

=GUARD(IF(User.IsDirty,2,0))

Now, I just needed to reset the User.IsDirty formula, so it will work again. Fortunately, the TheText cell in the Events section can react to a change in the text, so the following formula will re-instate the formula in the User.IsDirty cell:

=SETF(GetRef(User.IsDirty),"=ISERR(Fields.Value)")

This is possible because the Fields.Value is text in the above formula, so it will not get replaced with REF() in the SETF(…) formula.

  • Font color changes to Red when text is edited


So, I manually insert the Name Shape Data row back into the text, the color will automatically change back to Black.

  • Manually inserting the field
  • User.IsDirty formula automatically reset

Of course, the text field code be updated with some code, as follows, using the CALLTHIS(…) function:

  • Add Action to InsertField
  • VBA code to InsertField

The VBA sub-function ensures that the whole body of text is replaced with an inserted field:

Public Sub InsertField(ByVal shp As Visio.Shape, ByVal cellName As String)
Dim UndoScopeID1 As Long
  UndoScopeID1 = Application.BeginUndoScope("Set Text Field")
  Dim vsoChars As Visio.Characters
  Set vsoChars = shp.Characters
  vsoChars.Begin = 0
  vsoChars.End = Len(shp.Characters)
  vsoChars.AddCustomFieldU cellName, visFmtNumGenNoUnits
  Application.EndUndoScope UndoScopeID1, True
End Sub

Note that this solution only works for a single block of text, and not for large amounts of text where there are multiple inserted fields.

Related blogs

Fixing dimensions of 2D shapes

I am often asked what makes Visio unique and makes it stand out from the crowd, especially in today’s online world. Well, I think there are many reasons, but one of them is the ability to create scaled drawings with parametric components of specific dimensions. This was crucial for my adoption of Visio back in…

Smart Radio Buttons and Check Boxes in Visio

A recent project requires an interactive tutorial within Microsoft Visio desktop where a lot of the questions need a single answer using radio buttons, or multiple-choice answers using check boxes. I thought that this would be a great use of the list containers capability because the questions and answers could be part of the container…

Using Button Face Ids in Visio

Microsoft Visio desktop has the ability to display icons from a built-in list of Office icons on Actions and Action Tags (nee Smart Tags). These can be set in the ShapeSheet by using the desired number from several thousand in the ButtonFace cell. Although there is the ability to add better icons using code, the…

Grid Snapping Revisited

I have previously tackled the subject of snapping to grids in Visio desktop (see https://bvisual.net/2018/06/19/really-snapping-to-grids-in-visio/ ) but a recent project required me to improve the example because it did not respond to all cursor arrow keys. The problem was that the previous solution could not understand which arrow key had been clicked, therefore it did…

Optimize Visio Flowcharts: Swimlane Reordering Tips

Microsoft Visio desktop Plan 2 and Professional editions provides the ability to create and synchronize cross-functional flowcharts between the diagram and an Excel table. This is great, and widely used for many types of processes. The Excel table normally has a Function / Swimlane column that contains text that becomes labels on the swimlane containers,…

Linking Data to Shapes in Visio after using Data Visualizer

Data Visualizer (DV) in Visio Plan 2 (Data | Create from Data | Create ) is great because it provides a way of automatically creating a diagram from data, but it also prevents some of the other data-linking features in Visio from being used. This is because DV wants to take control of the data…

Related

Filed Under: Shape Data, ShapeSheet Formulas Tagged With: ShapeSheet Functions, VBA, Visio

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript LayerManager Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Setup and Deployment Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Validation VBA Video Visio Visio 2007 Visio for the Web Visio Online Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • Amazon
  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Search this website

Recent posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Copyright © 2025 · Executive Pro on Genesis Framework · WordPress · Log in