Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 490093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:52:26+00:00 2026-05-13T01:52:26+00:00

I need to access the VBA code of Office documents (Excel workbooks, but it’s

  • 0

I need to access the VBA code of Office documents (Excel workbooks, but it’s not relevant) through .Net / C#. I know how to do this, but this requires the Office user to have granted trusted access to the VBA project object model through the Office app.
This makes me uncomfortable, because there is a risk that the user leaves things set that way, which is not desirable, and because this requires the user to fire the Office app and change the settings if access has not been granted, which is not pleasant for the user.
I believe .Net code cannot change that setting automatically (which is good), but is there a way to ask the user if he/she wants to temporarily grant authorization? Or is there a way to give access to the VBE specifically to my application when it gets installed?
My assumption is that none of these are feasible, but I thought that if someone knew the answer, he/she would be on StackOverflow 🙂
As a bonus question, does anyone know how to programmatically check whether an Office app has granted access to the VBA project object model (without a try/catch that is…)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:52:27+00:00Added an answer on May 13, 2026 at 1:52 am

    Sadly what you’re requesting is possible by modifying the registry keys relating to security. You can set the registry key, perform the tasks that you require, then set the registry key back, as in the example below.

      Public Sub ModifyVBA()
        Set wsh = CreateObject("WScript.Shell")
        'key to modify
        keyName = "HKEY_LOCAL_MACHINE\Software\Microsoft\Office\" & _
            Application.Version & "\Excel\Security\AccessVBOM"
        'enable access
        wsh.RegWrite keyName, 1, "REG_DWORD"
        'read the vba project name
        Application.VBE.ActiveVBProject.VBComponents.Add (vbext_ct_ClassModule)
        'disable access
        wsh.RegDelete keyName
    End Sub
    

    (Disclaimer: I think I originally lifted this from another forum).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that's bad design, but I need access to the view from my
I'm working on excel with VBA and access and i need my system to
I need access to the uint64_t typedef from stdint.h in some wrapper code that
I need to access a RESTful server, which is not created with WCF. For
I have multiple sets of code I need to run in Access 2007 and
I'm processing an Excel workbook with Access VBA (see Reading an Excel workbook from
I have some files which need reading using Access / VBA. They are compressed
I am trying to write some vba code in Excel to query a table
I have this code to copy a sheet from a Workbook in VBA/Access to
I want to embed a simple piece of VBA Code in Access 2007. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.