Macro security levels

U

Uros

I would like to setup Macro security levels from VBA when starting my access
2003 application.

Is anybody knows how to do this.

Thanks!

Uros
 
B

Brendan Reynolds \(MVP\)

You need to do it from *outside* your MDB, as it takes effect before
anything *in* the MDB can run.

The code below is from a VB.NET console app with a reference added to the
Microsoft Access 11 Object Library, but presumably the same thing could be
done in VB6, or in VBA in Word or Excel. The code opens a new instance of
Access and opens an unsigned MDB, bypassing the security warning by
programmatically setting the 'macro' security level to low.

A couple of caveats ...

I've only played with this on my own system - I have not tested it in the
'real world'.

The AutomationSecurity property is new, and only
briefly documented, in Access 2003, but I understand it has been around for
some time now in Word and Excel, and I found everything I needed to know
about it in the Excel help file.

The Excel help file recommends setting the property back to its previous
value after opening the document. The example below doesn't do this, but it
would certainly be a good idea to do it in a real-world situation.

Module Module1

Sub Main()

Dim app As New Microsoft.Office.Interop.Access.Application
app.AutomationSecurity =
Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityLow
app.OpenCurrentDatabase("C:\SomeFolder\Some.mdb", True)
app.Visible = True

End Sub

End Module
 
U

Uros

Thanks for interesting solution ......

Uros

Brendan Reynolds (MVP) said:
You need to do it from *outside* your MDB, as it takes effect before
anything *in* the MDB can run.

The code below is from a VB.NET console app with a reference added to the
Microsoft Access 11 Object Library, but presumably the same thing could be
done in VB6, or in VBA in Word or Excel. The code opens a new instance of
Access and opens an unsigned MDB, bypassing the security warning by
programmatically setting the 'macro' security level to low.

A couple of caveats ...

I've only played with this on my own system - I have not tested it in the
'real world'.

The AutomationSecurity property is new, and only
briefly documented, in Access 2003, but I understand it has been around for
some time now in Word and Excel, and I found everything I needed to know
about it in the Excel help file.

The Excel help file recommends setting the property back to its previous
value after opening the document. The example below doesn't do this, but it
would certainly be a good idea to do it in a real-world situation.

Module Module1

Sub Main()

Dim app As New Microsoft.Office.Interop.Access.Application
app.AutomationSecurity =
Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityLow
app.OpenCurrentDatabase("C:\SomeFolder\Some.mdb", True)
app.Visible = True

End Sub

End Module
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top