locked
Office Trust Center registry keys not respected when using COM/OLE automation (p->invoke) RRS feed

  • Question

  • I have an application that is using COM (ie, "OLE automation") via p->invoke to perform certain processing on MS Office documents. Because the incoming documents are not necessarily trusted, I want to be able to block macros via the Trust Center registry keys (eg, HKCU\Software\Microsoft\Office\16.0\Word\Security\VBAWarnings=[1-4]). Curiously, though, I find that these settings under HKCU are never respected when I invoke Word in this way (although the key VBAOFF=1 under HKLM\Software\Policies\Microsoft\Office\16.0\Word\Security *does* work -- however, I find the latter setting is not suitable for my purposes, because it triggers modal dialogs that block new documents from being able to be processed by my application). Can anyone hazard a guess as to what may account for this behavior? (Based on looking at Procmon, I'm pretty confident that Office is just not even looking at these keys under HKCU when I invoke Word et al in this way -- they *do* work when I invoke Office applications manually in the usual fashion -- and even though I set them, I find that VBA macros inside of documents opened in this way will always run with impunity).
    • Edited by gberliner Tuesday, August 8, 2017 4:57 PM typo
    Monday, August 7, 2017 4:58 PM