Results 1 to 6 of 6

Thread: Programmatic access to Visual Basic is not trusted

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    2

    Programmatic access to Visual Basic is not trusted

    I want to export some data from my application to an excel sheet, in the export, I also want to create a macro command and add a checkbox associated to that macro, but I got an error because of the :
    Programmatic access to Visual Basic is not trusted

    I can resolve the problem by checking the option directly in Excel, but it is not a good way to resolve a problem since, I wont be the one using the app...

    Is there a way to programmaticly check the option in my VB code?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Programmatic access to Visual Basic is not trusted

    Sounds like you code is accessing the VBA IDE code? There is not way to "programmatically" check the "Trust" option.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    2

    Re: Programmatic access to Visual Basic is not trusted

    Tx, that is what I was afraid of.

    I thought there might have been a way by changing setting in the registry directly.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Programmatic access to Visual Basic is not trusted

    If there was a way, it would defeat the purpose of security for macros as code could run regardless of the users security settings, etc.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    New Member
    Join Date
    Jun 2009
    Posts
    1

    Re: Programmatic access to Visual Basic is not trusted

    Well, if by "check" you mean "click the checkbox", then yeah, I can see why that would be a security hole and hence it makes sense that it's not allowed. However, I found this thread because I was looking for a way to programmatically confirm the current setting (another definition of "check"... as in, to "check up on something"), and I get the impression that's not possible either. I'm trying to write a script that would create Macros if the user's security settings allowed, but if they didn't, it would quietly just not bother making any Macros rather than bombing out. Is there some way to peek in at the current setting programmatically?

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Programmatic access to Visual Basic is not trusted

    rightly or wrongly you can change the security setting by editing the registry key, but not while excel is open

    you can read the key to determine the security level while excel is open
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width