tags:

views:

66

answers:

3

Hey guys, 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 wanrning.

+4  A: 

Hi,

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, this seems to way to do it programatically. 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.

Trefex
thankyou. Is there any way to "embed" it in. I don't have the luxary to add a trusted location.
masfenix
Yes mate. Otherwise you would defeat the purpose of the security feature as a whole. Imagine me doing this, packing a VBA virus and sending you the file. If the file would auto-execute macros without asking me first, there would be no sense at all of having this added security feature.
Trefex
I see your point, thankyou very much.
masfenix
It doesn't make sense that you wouldn't have the 'luxury' of adding a trusted location. Of course you would. It's a work function and if they want it to operate, they'll allow it.
Fosco
Hey, Sorry what about when they enable it the first time, and then I can run some VBA code that puts it in the trusted location section?
masfenix
Editd my main post.
Trefex
+1  A: 

Have your macro signed by a trusted authority.

mcandre
+2  A: 

It's a per-user option. Everyone would need to 'trust' your workbook.

In Excel, hit the menu button, and choose Excel Options. In that window, pick Trust Center, and then Trust Center Settings. In that window, choose Trusted Locations.

Once on that screen, you will probably want to check "Allow Trusted Locations on my network" and then click Add Location and add the network location of your workbook.

Fosco