Is it possible to test if “Power Query for Excel” add-in is installed and enable using excel macros ?
I’d like to use it to authorize the Data refreshing of my workbook which is connected to several data sources using this add-in.
Thanks and Regards.
You could use something like this, as it’s a COM add-in:
Function IsPowerQueryAvailable() As Boolean Dim bAvailable As Boolean On Error Resume Next bAvailable = Application.COMAddIns("Microsoft.Mashup.Client.Excel").Connect On Error GoTo 0 IsPowerQueryAvailable = bAvailable End Function
If you actually wanted to try and enable it as well if it is present, you could use something like this:
Function IsPowerQueryConnected() As Boolean Dim bAvailable As Boolean Dim oPQ As COMAddIn On Error Resume Next Set oPQ = Application.COMAddIns("Microsoft.Mashup.Client.Excel") If Not oPQ Is Nothing Then If Not oPQ.Connect Then oPQ.Connect = True bAvailable = oPQ.Connect End If IsPowerQueryConnected = bAvailable End Function
You can check if addin is installed by:
Sub Foo() If AddIns("AddIn name").Installed Then 'installed Else 'not installed End If End Sub