Checking the edition of Visio 2010 at runtime


I thought I would share a common function that I use in all of my add-ins to help me determine if Visio is of the correct version and edition in order for my add-in to execute properly.

Copy and paste this into Visual Studio…

/// <summary>
/// Gets a value indicating whether the correct Version of Visio is installed.
/// <para></para>
/// Visio 2010 (14) or > and the Edition has to be anything other than STD.
/// </summary>
internal bool IsVisio14NotSTDInstalled
{
    get
    {
        bool retVal = false;

        // the installed version of Visio has to be 14 or > and the edition has to be PRO or >
        if (this.Application.TypelibMinorVersion >= 14)
        {
            if (this.Application.CurrentEdition != Microsoft.Office.Interop.Visio.VisEdition.visEditionStandard)
            {
                retVal = true;
            }
        }

        return retVal;
    }
}

Here is an example showing how I call this from the Startup handler in the ThisAddin class (VSTO based add-in)…

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    ...

    // check for Visio 2010 > and Edition >= PRO

    if (!this.IsVisio14NotSTDInstalled)

    {

        MessageBox.Show(

            Globals.ThisAddIn.VisioApplicationWindow,

            Properties.Resources.VisioVersionNotSupported_Message,

            Properties.Resources.errorAddin_Caption,

            MessageBoxButtons.OK,

            MessageBoxIcon.Error);

        return;

    }

    …

 

I perform this check at runtime because it is possible for the user to uninstall Visio and install another edition or version of Visio after the add-in is already installed on the system.  This is not a scenario that is common but it is still a nice check to help keep your add-in from failing or throwing exceptions in the event that this ever occurs.


Comments (2)

  1. al edlund says:

    for us that do it with vb…

    :-)

    ''' <summary>

    ''' Gets a value indicating whether the correct Version of Visio is installed.

    ''' <para></para>

    ''' Visio 2010 (14) or > and the Edition has to be anything other than STD.

    ''' </summary>

    Friend ReadOnly Property IsVisio14NotSTDInstalled() As Boolean

    Get
    
        Dim retVal As Boolean = False
    
        &#39; the installed version of Visio has to be 14 or &gt; and the edition has to be PRO or &gt; 
    
        If Me.Application.TypelibMinorVersion &gt;= 14 Then
    
            If Me.Application.CurrentEdition &lt;&gt; Microsoft.Office.Interop.Visio.VisEdition.visEditionStandard Then
    
                retVal = True
    
            End If
    
        End If
    
        Return retVal
    
    End Get
    

    End Property

  2. Ian T says:

    Is this possible using vbscript?  They had removed the edition signifier's in both registry and even in Win32_SoftwareFeature.  Thanks!