Thanks Graham! This worked a treat!
I do have 2 questions, though:
1.) In looking at this script, it appears that what it does is
programmatically set the macro security to low. I'm assuming that is file
specific, and wouldn't translate into every db my friend opens. Is that
right, or do I need to use an altered version of your wonderful code to make
an exit script setting it back to medium/high?
2.) This one's a bit trickier: I've been trying to think of a way to allow
my friend to define the path of the database here. I'm assuming if I insert
into your script an alteration of the Open/Save dialog that this shouldn't be
a problem. However; I'm looking to make it so that he can define the path
once, and not have to do it again until the path is changed.
If, for example, in addition to this, I throw in the script for the
Open/Save dialog (I won't paste it all here) and add in the following:
Dim strDBPath as String
strDBPath = <defined via open/save dialog>
Const cDatabaseToOpen = strDBPath
<resume the script you posted>
I'm no expert, but I think this will work where my friend can define the
path...but he'll have to do so every time he opens the database. Is there a
way to save the strDBPath and only redefine it if it is no longer valid?
If not, it's no huge deal, I would just prefer to tell him he can place his
db wherever he wants on his hard drive rather than forcing him to create a
static location defined by me.
TIA,
Tim
Graham Mandeno said:
Hi Tim
I understand your frustration!
Create a text file and paste the following VB Script code into it. Insert
the filename of the database in the obvious place and save it with a
filetype of ".vbs". Then open the script file directly or, if you prefer,
create a shortcut to the script file and put the MS Access icon on it.
========== start code ================
Const cDatabaseToOpen = "C:<path to your database>.mdb"
Const msoAutomationSecurityLow = 1
On Error Resume Next
Dim AcApp
Set AcApp = CreateObject("Access.Application")
If AcApp.Version = 11 Then
AcApp.AutomationSecurity = msoAutomationSecurityLow
End If
AcApp.OpenCurrentDatabase cDatabaseToOpen
If Err = 0 Then
AcApp.Visible = True
AcApp.UserControl = True
Else
AcApp.Quit
MsgBox "Failed to open '" & cDatabaseToOpen _
& "'." & vbCrLf & Err.Description
End If
========== end code ===================
--
Good luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
Hi there,
I have created a database for a friend of mine. He, understandably, is
reluctant to set his macro security to low. However, he also does not want
to be bothered by pesky security warnings whenever he opens the database. I
have tried using the selfcert.exe to sign the project, but he still gets a
warning everytime he opens it because it was created with my key (we're in
different states, so signing it on his computer isn't an option).
Because this is a 1 time thing, and I'm donating this to him, I really don't
want to pay a $100/yr subscription on something like VeriSign. Are there any
other alternatives?
Thanks in advance for any advice.