I have created many Visio solutions over the past 25 years and used a number of methods of creating an installation that includes Visio templates and stencils. I have just wasted many hours trying to debug an installation created with Advanced Installer until I realised that the problem was that Visio was not properly updating the cache of installed templates and stencils. In the end, the answer was to delete the cache and let Visio re-create it. The screenshots below show the custom shapes opened with the custom template and the More Shapes context menu. Before I deleted the cache, Visio incorrectly displayed the file name of some of the stencils (those with a trailing “_M” ) rather than the display name as entered into the PublishComponent table in Advanced Installer. In addition, the context menu did not show those stencils as being present in the workspace.
I realised that the problem stencils were those that contains Norwegian characters not found in English, and they had been problematic previously, so I tried editing my setup files many times, switching between English and Norwegian, but nothing worked. Actually it was working on my 64bit Visio installation but not on my 32bit Visio installation.
Visio has two files that it creates or updates on close. This is content16.dat and thumbs.dat which typically can be found in C:\Users\<username>\AppData\Local\Microsoft\Visio. One holds the information about each installed template and stencil and this was not getting updated. The other holds the preview images. Content16.dat can safely be deleted with Visio closed, because Visio will recreate it when it is opened, and saved to file when it is closed.
So, this solved the issue, but it is not a complete solution because the installer should cause this to refresh. To date I have been using a Custom Action in Advanced Installer that, I thought, would force this refresh. This vbscript bumps up the value of the ConfigChangeID in the registry.
Dim WshShell, visChangeId
Set WshShell = CreateObject("WScript.Shell")
On Error Resume Next
visChangeId = WshShell.RegRead ("HKLM\Software\Microsoft\Office\Visio\ConfigChangeID")
If Err = 0 Then WshShell.RegWrite "HKLM\Software\Microsoft\Office\Visio\ConfigChangeID", visChangeId + 1, "REG_DWORD"
However, I have recently been getting warnings in Advanced Installer that vbscript is being phased out. So perhaps that was the root cause of the problem. Fortunately Advanced Installer can use JavaScript as an alternative, so I will now try to replace the above script with the following:
const { execSync } = require('child_process');
try {
const visChangeId = execSync('reg query "HKLM\\Software\\Microsoft\\Office\\Visio" /v ConfigChangeID').toString().match(/ConfigChangeID\s+REG_DWORD\s+(\d+)/)[1];
const newVisChangeId = parseInt(visChangeId) + 1;
execSync(`reg add "HKLM\\Software\\Microsoft\\Office\\Visio" /v ConfigChangeID /t REG_DWORD /d ${newVisChangeId} /f`);
} catch (error) {
// Handle error if needed
}
Back to project work ….
Related articles
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…
New Requirement for VBA Digital Signatures in Visio
Like most developers, I have to buy a new digital certificate every 3 years to sign my Visio add-ins and VBA projects. Usually that means verifying my bone fides, paying the fee and downloading the certificate, but security has been increased, and now, like everyone else, I have to use a USB key with it…
Using Visio Color by Value on Connectors
Data Graphics in Visio Plan 2 and Visio Professional is great, but it only enables us to use them with 2D shapes in Visio, i.e. not on connectors. So, what if you want to change the line colour of the connectors between the 2D shapes because of the data flowing between them? Well, it is…
Counting glued and connected shapes in Visio
I got a surprise in one of my projects when I counted the shapes glued together using the Shape.GluedShapes(…) method … the sum of the filtered glued shapes just didn’t add up to the unfiltered count. So, I thought I should check the Shape.ConnectedShapes(…) method too … and there is a scenario where that has…
Linking Data to Visio Shapes in Code
One of the most useful capabilities of Visio Professional and Visio Plan 2 is to link external data to shapes and have them refreshed by changes in the data source. So, many of my solutions involve writing code to make these links, and they are covered with some VBA examples in my book, Mastering Data…
Leave a Reply