Il modo migliore per rilevare se è installato VBA è quello di utilizzare l'API MsiQueryFeatureState e chiedere di Windows Installer se la funzione è installato o non. Di seguito è riportato un codice di esempio in VB.NET, tuttavia è possibile codificarlo in qualsiasi lingua che consenta di chiamare i componenti COM (mi dispiace, non ho familiarità con InnoSetup).
Private Declare Function MsiQueryFeatureState Lib "Msi" Alias "MsiQueryFeatureStateA" (ByVal Product As String, ByVal Feature As String) As Long
Public Function FVbaAvailable() As Boolean
Dim objExcelApp As Object
Dim strProductCode As String
Dim nState As Long
Dim fAvailable As Boolean = False
Try
' Start an Excel instance and get the product code.
objExcelApp = CreateObject("Excel.Application")
strProductCode = DirectCast(objExcelApp.ProductCode, String)
' Get FeatureState for the VBAFiles Feature.
nState = MsiQueryFeatureState(strProductCode, "VBAFiles")
If (nState = 1) OrElse (nState = 3) OrElse (nState = 4) Then
' VBA is available.
fAvailable = True
End If
' Clean up.
objExcelApp.Quit()
Runtime.InteropServices.Marshal.FinalReleaseComObject(objExcelApp)
objExcelApp = Nothing
Catch ex As Exception
Trace.WriteLine(ex.Message)
End Try
Return fAvailable
End Function
fonte
2015-04-09 07:52:05
Questo non funziona per Office 365, sfortunatamente. –