locked
How to determine whether VBA is installed by Click-To-Run Office installer RRS feed

  • Question

  • Hi,

    There was a nice article describing how to determine if VBA feature is installed in Office 2003.
    (it was called: How to determine whether VBA is enabled for Office applications)

    The solution was using MSI API:

    MsiQueryFeatureState(szCode, "VBAFiles")

    It worked also for Office 2010 and 2013.
    My problem is that it does not work for Office 2016.
    Is it possible to use MSI API to check if VBA feature is installed in Office 2016?

    Regards

    Dawid


    Wednesday, May 4, 2016 11:58 AM

All replies

  • Hello Dawid,

    Do you have the Click2Run edition of MS Office 2016 installed on the machine?

    Note, the MsiQueryFeatureState function makes sense only if MSI installer was used. Take a look at the following links for more information:

    Verify if Outlook Is a Click-to-Run Application on a Computer

    Determining if an Office Installation is Click-to-Run or Not


    [custom.development]

    Wednesday, May 4, 2016 1:55 PM
  • Hi Dawid,

    >>My problem is that it does not work for Office 2016.

    Did you get any error message? Based on my test, it also works well for me(Office 216, Click-to-Run). Here is the code for your reference:

    Private Declare Function MsiQueryFeatureState Lib "Msi" Alias "MsiQueryFeatureStateA" (ByVal Product As String, ByVal Feature As String) As Long
    
    Private Sub Command1_Click()
       ' Start Word.
       Dim wdApp as Object
       Set wdApp = CreateObject("Word.Application")
     
       ' Get the Product Code.
       Dim szCode as String
       szCode = wdApp.ProductCode
    
       ' Get FeatureState for the VBAFiles Feature.
       Dim x as Long
       x = MsiQueryFeatureState(szCode, "VBAFiles")
    
       If (x = 1) Or (x = 3) Or (x = 4) Then
          MsgBox "VBA is installed"
       Else
          MsgBox "VBA is NOT installed"
       End If
    
    End Sub

    Would you mind sharing more detail about the environment and steps to help us to narrow this issue?

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 5, 2016 2:18 AM
  • Hello Eugene,

    Thanks for the info.

    It looks like currently I have Click2Run edition of MS Office 2016 installed.

    The key value exists in the registry (shame I am not able to add images to show it :( )

    HKEY_LOCAL_MACHINE\Software\Microsoft\Office\15.0\Common\InstallRoot\Virtual\Virtual

    Excel has the text about updates on it's backstage File->Account form ("Updates for this product are available for the dowload")

    Regards

    Dawid

    Thursday, May 5, 2016 6:30 AM
  • Hi Dawid,

    >>My problem is that it does not work for Office 2016.

    Did you get any error message? Based on my test, it also works well for me(Office 216, Click-to-Run). Here is the code for your reference:

    Private Declare Function MsiQueryFeatureState Lib "Msi" Alias "MsiQueryFeatureStateA" (ByVal Product As String, ByVal Feature As String) As Long
    
    Private Sub Command1_Click()
       ' Start Word.
       Dim wdApp as Object
       Set wdApp = CreateObject("Word.Application")
     
       ' Get the Product Code.
       Dim szCode as String
       szCode = wdApp.ProductCode
    
       ' Get FeatureState for the VBAFiles Feature.
       Dim x as Long
       x = MsiQueryFeatureState(szCode, "VBAFiles")
    
       If (x = 1) Or (x = 3) Or (x = 4) Then
          MsgBox "VBA is installed"
       Else
          MsgBox "VBA is NOT installed"
       End If
    
    End Sub

    Would you mind sharing more detail about the environment and steps to help us to narrow this issue?

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Hello Fei,

    Thanks for the replay.

    This MsiQueryFeatureStateA worked with older version of Office 2016 (possibly because it was MSI install).
    Now I have installed latest Office 2016 from MSDN (it appears to be Click2Run install like Eugene suggested)

    The product code is: "{90160000-000F-0000-1000-0000000FF1CE}"

    Query MsiQueryFeatureStateA returns INSTALLSTATE_UNKNOWN.

    Regards

    Dawid

    Thursday, May 5, 2016 6:48 AM
  • Hi Dawid,

    Thanks for the detail information for this issue. 

    I am failed to reproduce this issue with Office 365 click-to-run, here is the figure for the version information:

    However, the product code is "{90160000-000F-0000-0000-0000000FF1CE}" which is defferent with yours. Would you minding sharing the detail version of Office you were using?

    In addition, did you install the old version of Office on the same machine? If yes, I suggest that you try to install the Office 2016 to a clean machine to see whether this issue was fixed.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, May 6, 2016 2:44 AM
  • Hello Fei,

    This is my office version: 16.0.6868.2060

    On my box I first had Office 2013. It was uninstalled and Office 2016 was installed after that.

    My colleague was testing this on a clean virual machine. He had the same behaviour.

    Regards
    Dawid

    Tuesday, May 10, 2016 12:09 PM
  • Hi Dawid,

    Did you bought the one of the Office 2016 suites of products, such as Office Home & Student 2016 or purchase an Office 365 subscription?

    The above test is using the Office 2016 which contained in the Office 365.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 11, 2016 9:18 AM
  • Hi Fei,

    I have installed my Office 2016 from ISO image downloaded from my MSDN subscription.

    Regards
    Dawid



    Friday, May 13, 2016 5:15 AM
  • Hi Dawid,

    Thanks for the detail information for the Office version.

    I also test the code with Office Professional Plus 2016 and it also works well for me.

    Would you mind sharing a screenshot for the detail version information about Office?

    You can get the version information via File->Account. And if you were not able to paste the picture in this forum, you can upload the picture via OneDrive and share the link here.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 18, 2016 2:42 AM