none
Cannot create VBScript engine in an Office COM-Addin RRS feed

  • Question

  • Hi,

    We have Office COM-Addins (using VSTO) for Word, Excel, Outlook, Powerpoint, Visio and Project.

    In these Addins we are using the VBScript script engine. the flow is basically:

    Addin -> COM object (in C++) -> tries to use VBScript.

    Since Office 2016 v1806 (Build 10228.20080), the creation of the VBscript engine fails with:

    hr = CoCreateInstance(CLSID_VBScript, NULL, CLSCTX_INPROC_SERVER, IID_IActiveScript, (void**)&m_pActiveScript);

    hr: 0x80070005: Access is denied


    This happens for Word, Excel, Powerpoint (and probably Visio and Project too, untested). Outlook still works as before, and is NOT failing.

    Reverting to Office 2016 v1805 (Build 9330.2124) fixes the problem and everything works again, as it worked since Office 2007, but that is not a solution to this problem.
    Are there some options to enable the old behavior? Is this a bug?

    Any help appreciated!

    Also note: This here seems to be a similar issue, it seems it has the same root cause: (search for it, i cannot post links...)

    "Access 2016 - Microsoft Script Control stopped working (Error 380)"
    Thursday, July 5, 2018 3:32 PM

Answers

  • Update: the Installation of Microsoft Office 16.0.10228.20104 erases some of the below recommended registry settings which reactivates the VBScript usage filter, hence stopping (functionality of) your COM AddIN. You need to re-apply the registry canges/fixes from below.

    ---

    The best solution identified is to modify the registry after Office Update 1806. Details and future updates on this will be posted on help.process4.biz/confluence/x/CwAzAQ

    Solution Summary:

    1. download or create the file process4FixPermissionForComAddINs.reg (on our help site) with the following content:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Office\16.0\Common\COM Compatibility\{B54F3741-5B07-11cf-A4B0-00AA004A55E8}]
    "ActivationFilterOverride"=dword:00000001

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Wow6432Node\Microsoft\Office\16.0\Common\COM Compatibility\{B54F3741-5B07-11cf-A4B0-00AA004A55E8}]
    "ActivationFilterOverride"=dword:00000001

    2. Run (double-click) the .reg file
    3. If you want to get control when the next Office Update hits you, you can change/turn off your Office Updates setting, or use Update Policies. You might need to reapply this fix after future Office Updates.

    Tuesday, July 10, 2018 10:32 AM

All replies

  • We have the exact same problem in our COM Addin for Word.

    The CoCreateInstance call is failing with the "Access is denied" result.

    Thursday, July 5, 2018 8:58 PM
  • I have created a minimal repro for this problem.

    1) Create a new VSTO addin for Word (or Excel or Powerpoint etc)

    2) Use this code in ThisAddin_Startup

    	[DllImport("ole32.dll", EntryPoint = "CoCreateInstance", CallingConvention = CallingConvention.StdCall)]
    	static extern UInt32 CoCreateInstance([In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid,
    		IntPtr pUnkOuter, UInt32 dwClsContext, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid,
    		[MarshalAs(UnmanagedType.IUnknown)] out object rReturnedComObject);
    
    	private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
    		Guid VbScriptClassId = Guid.Parse("{B54F3741-5B07-11cf-A4B0-00AA004A55E8}");
    		uint CLSCTX_INPROC_SERVER = 1;
    		Guid IID_IActiveScript = Guid.Parse("{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}");
    		object IActiveScriptObject = null;
    
    		UInt32 hr = CoCreateInstance(VbScriptClassId, IntPtr.Zero, CLSCTX_INPROC_SERVER, IID_IActiveScript, out IActiveScriptObject);
    		System.Windows.Forms.MessageBox.Show("Result HR: " + hr.ToString("x"));
    	}

    3) Compile and register the addin

    4) The messagebox will say "2147942405" which is 0x80070005 -> Access is denied

    Friday, July 6, 2018 1:18 PM
  • I want to confirm you are not alone with this. We face the same issue on Visio.

    We have raised a ticket at portal.office.com/Support/AltUSupport.aspx ticket # 10716257 (no answer from Microsoft yet). Since you are MPN too I recommend you rasing a ticket there too, you can also reference our ticket. Maybe together we will get more attention. If you leave your ticket number here I can reference it in case of escalation that I need to get rolling early next week, if we face no answer or no progress.

    We have several of our best developers working exclusively on this, but it seems there is no way around Microsoft fixing it.

    The currently best possible solution that we recomment our affected customers is (like you also found out in parallel) to roll back.

    The problem is caused by the recent Microsoft update 1806 (June 2018), which forbids add-ins to use the VBScript engine. Therefore, the only working solution right now (06. July 2018) is to downgrade your Office to a previous version:

    1. Use shortcut Win + R, type cmd and click OK to start the command line
    2. Change to directory where Office is installed by typing: cd %programfiles%\Common Files\Microsoft Shared\ClickToRun 
    3. Now execute command to downgrade Microsoft Office to the last version that is known to work: officec2rclient.exe /update user updatetoversion=16.0.9330.2124 
    4. process4.biz and other Office Add-INs are now working again. 
    5. Do not forget to turn off automatic Office Updates.
    Friday, July 6, 2018 3:07 PM
  • Update on the youtcome of portal.office.com/Support/AltUSupport.aspx ticket # 10716257

    This is Z** from Office 365 contacting you in regards to your ticket. I have read through the documentation you have sent me and due to this being a third party application issue I will not be able to assist you at this time. Unfortunately we as members of this team would not be trained to deal with a problem of this caliber. I can give you the link to the Office Development Center for you to raise this issue to see if you can find a further resolve.

    techcommunity.microsoft.com/t5/Office-365/ct-p/Office365

    Friday, July 6, 2018 4:52 PM
  • Maybe a workaround would be to move the functionality that instantiates and uses the VBScript Engine into an out-of process server ( your own or use the DLL surrogate). 

    • Edited by RLWA32 Friday, July 6, 2018 5:20 PM
    Friday, July 6, 2018 5:20 PM
  • This is now referenced by GetHelp ID Case 10924945
    Friday, July 6, 2018 7:58 PM
  • Link to a similar / related issue with likely the same root cause:
    social.msdn.microsoft.com/Forums/windows/en-US/45c14333-3685-4b2d-9a3a-6a109a5a2a86/access-2016-microsoft-script-control-stopped-working-error-380?forum=accessdev
    Monday, July 9, 2018 5:08 PM
  • My latest information is, that this issue was escalated to Microsoft Engineering and we are waiting for an answer/solution.
    Tuesday, July 10, 2018 7:37 AM
  • Update: the Installation of Microsoft Office 16.0.10228.20104 erases some of the below recommended registry settings which reactivates the VBScript usage filter, hence stopping (functionality of) your COM AddIN. You need to re-apply the registry canges/fixes from below.

    ---

    The best solution identified is to modify the registry after Office Update 1806. Details and future updates on this will be posted on help.process4.biz/confluence/x/CwAzAQ

    Solution Summary:

    1. download or create the file process4FixPermissionForComAddINs.reg (on our help site) with the following content:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Office\16.0\Common\COM Compatibility\{B54F3741-5B07-11cf-A4B0-00AA004A55E8}]
    "ActivationFilterOverride"=dword:00000001

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Wow6432Node\Microsoft\Office\16.0\Common\COM Compatibility\{B54F3741-5B07-11cf-A4B0-00AA004A55E8}]
    "ActivationFilterOverride"=dword:00000001

    2. Run (double-click) the .reg file
    3. If you want to get control when the next Office Update hits you, you can change/turn off your Office Updates setting, or use Update Policies. You might need to reapply this fix after future Office Updates.

    Tuesday, July 10, 2018 10:32 AM
  • @process4.biz Thanks, that seems way better than reverting to a previous version.
    Tuesday, July 10, 2018 12:20 PM
  • The solution above works ok, but the note is if we apply given Registry changes before Office update, updating to 10228.20080 will erase changes and the issue will come back.
    Another solution (based on the same document) is following:

    We can just disable OLE/COM components filtering for the destination Office application (let's call it {APP_NAME}):

    For 64-bit Office installations and 32-bit Office installations on 32-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Office\16.0\{APP_NAME}\Security
    DWORD ActivationFilter = 0

    For 64-bit Office installations and 32-bit Office installations on 32-bit OS:
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Microsoft\Office\16.0\{APP_NAME}\Security
    DWORD ActivationFilter = 0

    The advantage of this approach is that it can be used anytime, no matter installed update 10228.20080 or still not - changes will stay and work after update.

    • Edited by Happyphant Thursday, July 12, 2018 5:24 AM
    Thursday, July 12, 2018 5:21 AM