none
Office 2013 COM-Exception Programmatic Access to Visual Basic project is not trusted occurs RRS feed

  • Question

  • This is specific to Word in Office 2013.  I have Trust Access to the VBA Project Model enabled.  I then launch Word programatically via the Interop library.  When I try to access the VBE object, the COM-Exception Programmatic Access to Visual Basic project is not trusted occurs.  So I go back into the Word Trust Center settings and make sure the check box is still ticked, it is.  When I close out of the Trust Center settings, I no longer get the exception.  So I close Word and try to run it through my program again, and the COM exception happens again.  It's like the Trust Center settings aren't being read properly at program launch.  I've gone to the Registry to ensure the setting is being stored, HKCU\SOFTWARE\Microsoft\Office\15.0\Word\Security\AccessVBOM is 1, and there is no override at the same location except HKLM.  Here is the code:

    try
    {
    	WordApp = new Word.Application();
    	WordApp.Visible = true;
    
    	if (WordApp.VBE != null)
    	{
    		// VBA Access is enabled
    	}
    }
    catch (Exception ex)
    { 
    	// Trust or the VBA Project Model has not been enabled
    }
    


    • Edited by Middas Monday, October 22, 2012 6:06 PM
    Monday, October 22, 2012 5:40 PM

Answers

  • Nevermind, I was able to get what I needed through the Document object.
    • Marked as answer by Middas Monday, October 22, 2012 6:41 PM
    Monday, October 22, 2012 6:41 PM

All replies

  • Nevermind, I was able to get what I needed through the Document object.
    • Marked as answer by Middas Monday, October 22, 2012 6:41 PM
    Monday, October 22, 2012 6:41 PM
  • Hi Middas,

    I'm glad to learn you have solved your issue via yourself. Would you share your work round here, it might be great helpful for other community members who have similar issue to see how your solved it.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, October 23, 2012 5:38 AM
    Moderator