automationsecurity

S

skchth

Using the vbscript:

dim o
set o=createobject ("Access.Application")
o.automationsecurity=1 ' set macro security LOW.
o.opencurrentdatabase "C:\Database\db1.mdb"
o.visible=true
o.usercontrol=true
set o=nothing

given by TC returns the error message that the database can not be found or
doesn't exist. However, when I set the security level in my database to low,
I am able to open the database using the vbscript.
I also tried

Const cDatabaseToOpen = "C:\Database\db1.mdb"
On Error Resume Next
Dim AcApp
Set AcApp = CreateObject("Access.Application")
If Val (AcApp.Version) >= 11 Then
AcApp.AutomationSecurity = msautomationsecuritylow
End If
AcApp.Visible = True
AcApp.OpenCurrentDatabase cDatabaseToOpen
If AcApp.CurrentProject.FullName <> "" Then
AcApp.UserControl = True
Else
AcApp.Quit
MsgBox "Failed to open '" & cDatabaseToOpen & "'."
End If

which returns the error message that the database failed to open. What am I
doing wrong?
Thanks for all the help
 
T

TC

skchth said:
Using the vbscript:

dim o
set o=createobject ("Access.Application")
o.automationsecurity=1 ' set macro security LOW.
o.opencurrentdatabase "C:\Database\db1.mdb"
o.visible=true
o.usercontrol=true
set o=nothing

given by TC returns the error message that the database can not be found or
doesn't exist. However, when I set the security level in my database to low,
I am able to open the database using the vbscript.
(snip)

Can you post the /exact/ code that does not find the database?
Presumeably it is not the code above. I need to see the /exact/ code.
 
S

skchth

TC,

I wrote this code in a Notepad document:
dim o
set o=createobject ("Access.Application")
o.automationsecurity=1 ' set macro security LOW.
o.opencurrentdatabase "C:\Database\db1.mdb"
o.visible=true
o.usercontrol=true
set o=nothing
and saved it as a VBS file.
After opening this file, I received the error message:
Microsoft Office Access can't open the database because it is missing, or
opened exclusively by another user.
When I set the security setting to "low", I will be able to open the
database by using the vsb file. First I thought that it might have to do with
my database, however when I created a new one, I received the same message.
The databse I'm using is not secured with a password or workgroup.
I hope you will be easy on me because I am only a beginner.
Thanks a lot for your help.
By the way I like your website with the Javascript Zoomer.
 
T

TC

Hi,

My code asumes that the database file is called "db1.mdb" and that it
is in the directory "Database" on your C: drive. But that was just for
the sake of example. You need to edit that line to use the correct name
& location of your own database file. So if your own file was called
"Rentals.mdb", and it was in the "My Documents" folder of your D:
drive, you'd change that line to:

o.opencurrentdatabase "D:\My Documents\Rentals.mdb"

Thanks for the comment on the Javascript Zoomer! I wish that I'd
invented it! Another guy invented it. I give a link to him on my site.
But he doesn't give his name, and he called it a DOM magnifier. I think
Javascript Zoomer is much more exciting!

Cheers,
TC (MVP Access)
http://tc2.atspace.com
 
S

skchth

TC,

I did create the "database" folder on my C:\drive and named my database
"db1". However, I did discover why it is not working. For some reason, the
vsb script does not open with the wscript.exe file in c:\windows\system32,
which I guess is required. I think that somehow the system administrators
prevent me of using wscript.exe. I tried your code on a computer that is not
connected to my company's network and your script worked perfect. Now I have
to find an alternative to wscript.exe because the system administrators
refuse to change the settings.
Again, thank you very much for your help.
 
T

TC

Ok, glad I could help.

The next version of Access will have a better method of supressing the
security warnings. Maybe you could put up with the warnings, until
then.

TC (MVP Access)
http://tc2.atspace.com
 

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