Chris Hopkins' Blog - #makinitdostuff

The place where I post information about the products I manage; SharePoint, Yammer, Project and Visio and maybe from some that I don't!

Checking the edition of Visio 2010 at runtime

Checking the edition of Visio 2010 at runtime

  • Comments 2

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.

Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post
  • 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

    ' the installed version of Visio has to be 14 or > and the edition has to be PRO or >

    If Me.Application.TypelibMinorVersion >= 14 Then

    If Me.Application.CurrentEdition <> Microsoft.Office.Interop.Visio.VisEdition.visEditionStandard Then

    retVal = True

    End If

    End If

    Return retVal

    End Get

    End Property

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

Page 1 of 1 (2 items)