Avoid security alert in .accde

fibonacci

Registered User.
Local time
Today, 05:41
Joined
May 5, 2015
Messages
13
Hello evryone,
I created the .accde to distribute only the compiled file.
But I have a problem.
When you open the file .accde there is this problem of security:
You can not determine whether the content is from a trusted source.
Leave off the contents, unless they provide essential capabilities and the source is considered reliable.
Open the file or cancel the operation?

How Can I avoid the visualization of this security alert?

Thanks in advance
 
the users need to set the document as trusted.

if they are using runtime, they can't do this. They just have to accept it.
 
you can set the trusted location from a vb script. if you package and deploy you can have a vb script run as part of the installation process

Or you can have some code in vba which does the same thing - problem with the latter is the user will see and need to click the 'enable content button' for the code to run.

see these links for more detail

http://www.tek-tips.com/viewthread.cfm?qid=1718392
http://www.access-programmers.co.uk/forums/showthread.php?t=217954
 
Thank you.
But isn't something absolutely necessary. I thought enough
lower the level of security. I leave it, not a problem
 
Last edited:
just realised

need to click the 'enable content button' for the code to run

should be

need to click the 'enable content button' for the code to run the first time
 
just realised

need to click the 'enable content button' for the code to run

should be

need to click the 'enable content button' for the code to run the first time
Forgive my ignorance but I have some doubts.
I must put the 2 functions:
Function TrustedLocation()
TrustedLocationAllowSubFolders
in a new module. It is right?
And in value I must insert the path where is my app in .accde (the compiled version)? In this case I force my app to stay in an path.
And for myApp the extension is necessary also?

Thanks for your patience
 
I must put the 2 functions:
Function TrustedLocation()
TrustedLocationAllowSubFolders
in a new module. It is right?
you can do, or you could put it in the 'autoexec form' form. It is up to you whether you allow subfolders, if you don't use them you don't need to worry.

In your current db, click on file>options>trust centre>trust centre settings>trusted locations to see what is required.

if you are not specifying the location (which you would be with package and deploy) then the path would be found in

currentdb.name

which includes both the path and the name

however you only want the path, so you need to strip off the file name and extension
 
you can do, or you could put it in the 'autoexec form' form. It is up to you whether you allow subfolders, if you don't use them you don't need to worry.

In your current db, click on file>options>trust centre>trust centre settings>trusted locations to see what is required.

if you are not specifying the location (which you would be with package and deploy) then the path would be found in

currentdb.name

which includes both the path and the name

however you only want the path, so you need to strip off the file name and extension
This is the code that I used ,embedded in the macro autoexec ,but it does not work.
Where am I wrong?

Code:
Function autoexec()
On Error GoTo autoexec_Err
    AddTrustedLocation
    DoCmd.OpenForm "Menu", acNormal, "", "", , acNormal
    
 autoexec_Exit:
    Exit Function
 autoexec_Err:
    MsgBox Error$
    Resume autoexec_Exit
 End Function
  
 Public Function AddTrustedLocation()
On Error GoTo err_proc
'WARNING:  THIS CODE MODIFIES THE REGISTRY
'sets registry key for 'trusted location'
    Dim intLocns As Integer
   Dim i As Integer
   Dim intNotUsed As Integer
   Dim strLnKey As String
   Dim reg As Object
   Dim strPath As String
   Dim strTitle As String
   
   strTitle = "Add Trusted Location"
   Set reg = CreateObject("wscript.shell")
   strPath = CurrentProject.Path
    'Specify the registry trusted locations path for the version of Access used
   strLnKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\" & Format(Application.Version, "##,##0.0") & _
              "\Access\Security\Trusted Locations\Location"
 On Error GoTo err_proc0
   'find top of range of trusted locations references in registry
   For i = 999 To 0 Step -1
       reg.RegRead strLnKey & i & "\Gestione VolumiProva7.accde"
       GoTo chckRegPths        'Reg.RegRead successful, location exists > check for path in all locations 0 - i.
checknext:
   Next
   MsgBox "Unexpected Error - No Registry Locations found", vbExclamation
   GoTo exit_proc
   
   
chckRegPths:
'Check if Currentdb path already a trusted location
'reg.RegRead fails before intlocns = i then the registry location is unused and
'will be used for new trusted location if path not already in registy
 On Error GoTo err_proc1:
   For intLocns = 1 To i
       reg.RegRead strLnKey & intLocns & "\Gestione VolumiProva7.accde"
       'If Path already in registry -> exit
       If InStr(1, reg.RegRead(strLnKey & intLocns & "\Gestione VolumiProva7.accde"), strPath) = 1 Then GoTo exit_proc
NextLocn:
   Next
   
   If intLocns = 999 Then
       MsgBox "Location count exceeded - unable to write trusted location to registry", vbInformation, strTitle
       GoTo exit_proc
   End If
   'if no unused location found then set new location for path
   If intNotUsed = 0 Then intNotUsed = i + 1
   
'Write Trusted Location regstry key to unused location in registry
On Error GoTo err_proc:
   strLnKey = strLnKey & intNotUsed & "\"
   reg.RegWrite strLnKey & "AllowSubfolders", 1, "REG_DWORD"
   reg.RegWrite strLnKey & "Date", Now(), "REG_SZ"
   reg.RegWrite strLnKey & "Description", Application.CurrentProject.Name, "REG_SZ"
   reg.RegWrite strLnKey & "Path", strPath & "\", "REG_SZ"
   
exit_proc:
   Set reg = Nothing
   Exit Function
   
err_proc0:
   Resume checknext
   
err_proc1:
   If intNotUsed = 0 Then intNotUsed = intLocns
   Resume NextLocn
 err_proc:
   MsgBox Err.Description, , strTitle
   Resume exit_proc
   
End Function
 
This is the code that I used ,embedded in the macro autoexec ,but it does not work.
Where am I wrong?

Chicken and egg problem. The code won't run until it is in a Trusted Location.

Think about it. What would be the point of allowing code to run that would completely bypass the security?

The best solution was deprecated by Microsoft in Access 2007. It is the main reason why I still use mde where the code can be digitally signed.
 
without knowing what 'does not work' means I cant offer any advice - does the code run? does it generate any errors? have you stepped through the code?

Galaxiom is right - it won't run unless it is in a trusted location - or the user has clicked the enable button - have they clicked the button?
 
As mentioned above I do not want to fiddle with it. It was just to perfect but not a priority.
So I thank you warmly and I give up
 

Users who are viewing this thread

Back
Top Bottom