Search code examples
vb.netpowerpointinno-setupoffice-interop

Using Office Interop Application Object to get the PowerPoint version during installation with Inno Setup


During the installation of our PowerPoint add-in using Inno Setup installer, I need to get the currently used version of PowerPoint by querying an Application.PowerPoint object itself – instead of relying on registry entries which can't be guaranteed to give the correct value.

I have successfully implemented this for an MSI installer written with WIX based on this answer using this code:

Imports Microsoft.Office.Interop.PowerPoint

Public Class Environment

  Public Shared Function GetPowerPointVersion() As String

    Dim CurVer As String
    Dim thisPowerPoint As Object

    thisPowerPoint = New Application()
    CurVer = thisPowerPoint.Version
    thisPowerPoint.Quit()

    Return CurVer

  End Function

End Class

I don't entirely trust this to work in all situations (maybe paranoid), so will put in try/catch blocks and use the registry method if this fails.

I haven't been able to work out how to do a similar thing with Inno Setup installer. There are some examples of using DLLs – https://jrsoftware.org/ishelp/index.php?topic=scriptdll – but I can't see how I could create a function callable from Inno Setup from this which would return the version number.


Solution

  • You can use CreateOleObject to call PowerPoint and return the version:

    [Code]
    function GetPowerPointVersion(): string;
    var
      MyPowerPoint: Variant;
    begin
      MyPowerPoint := CreateOleObject('PowerPoint.Application');
      Result := MyPowerPoint.Version;
      MyPowerPoint.Quit;
    end;