Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of VBA security warning

I developed a Access application using VBA. Everytime I open Access up, I get the following:

https://lh5.googleusercontent.com/wgn5B5PllVXGuG6W4_xiFa1rouSpDSn27MC0nzPkgJ5CPN8BKpAn-gDFsVS4GZtepY-c4jtbEupKeV227ogICQlzcg=s512

I have to click Options -> Enable Content to run my macros. This application will be shared among a couple of people at work who are not so tech savvy. So as per requirements, I must remove it. I've tried signing/packaging the database, but it still does not get rid of the warning.

like image 916
masfenix Avatar asked Jul 07 '10 14:07

masfenix


People also ask

How do I turn off the security warning when opening a link?

Type Security, and then press Enter to name the key. On the Edit menu, point to New, and then click DWORD Value. Type DisableHyperlinkWarning, and then press Enter to name the entry. In the right pane, right-click DisableHyperlinkWarning, and then click Modify.

How do I stop Microsoft Excel from blocking macros?

For an individual file, such as a file downloaded from an internet location or an email attachment the user has saved to their local device, the simplest way to unblock macros is to remove Mark of the Web. To remove, right-click on the file, choose Properties, and then select the Unblock checkbox on the General tab.


1 Answers

To do that you have to add the location from where the Excel is launched in the "Trusted Locations".

To do this, do as follows:

  • In Excel Options, go to Trust Center and then Trusted Locations
  • Add the location.

This would have to be done on a per-pc basis.

In addition, there is no way to do this from an Excel file point of view as this would completely anihiliate the security feature of letting the user chose to run VBA code or not.

Also a little sidenote, if you sign your Excel file, you'd still need the recipient to trust you as a publisher, so that's why your solution probably did not work.

Edit:

Taking into comments, there does seem to be a way to do it programmatically. As taken from XpertsExchange,

Why not just set the registry entry from code, without invoking Shell? Use the cRegistry class found here:

http://www.vbaccelerator.com/home/VB/Code/Libraries/Registry_and_Ini_Files/Complete_Registry_Control/article.asp

VBA Code:

 Dim c As New cRegistry
    With c
        .ClassKey = HKEY_CURRENT_USER
        .SectionKey = "Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\YourTrustedLocationName"
        .ValueKey = "Path"
        .ValueType = REG_DWORD
        .Value = "Full path to Trusted Folder"
    End With

The only caveat is that YourTrustedLocationname must be unique ...

You'd have to try if it should be .ValueType = REG_DWORD or REG_SZ. I'm not sure on that one.

like image 59
Trefex Avatar answered Oct 16 '22 16:10

Trefex