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.