Open Access automatically

G

Guest

I would like to open an Access database from Excel. I can do this but the
user still has to click the open button. Is there a way to programatically
click the "open" button?

Thanks for the help....
 
G

Guest

you should post such questions in an excel forum.

You can do this using the OpenDatabase() function.

Also I came across the following on google just to give you a few more
options.

*****
You can call it a couple of ways...See below.
I prefer using the 'Shell' option. A LOT less messy.
HTH,
Gary Brown

'/===================================/
Sub test_Shell()
Dim strAccessProgramLocation As String
Dim retVal As Variant

'put location of MS Access program in string
strAccessProgramLocation = _
"C:\Program Files\Microsoft Office\Office\msaccess.exe"

'call MS Access from Excel
retVal = Shell(strAccessProgramLocation, vbNormalFocus)

End Sub
'/===================================/
Sub test_App()
'create a reference to...
'Microsoft Access 9.0 Object Library
' Probably located at...
' C:\Program Files\Microsoft Office\Office\MSACC9.OLB
Dim objAccess As Access.Application

Set objAccess = New Access.Application

objAccess.Visible = True

MsgBox "Access Closed"

exit_Sub:
Set objAccess = Nothing
Exit Sub

End Sub
'/===================================/
*****

Daniel
 
G

Guest

Do you mean the Access security 'Open' button?

If so, you can bypass these by changing the Windows Registry Settings -
usual warnings about being careful doing this and, of course, you need to be
happy that the security checks aren't made.

The settings are (you may need to create the keys):

HKEY_LOCAL_MACINE\Microsoft\Office\11.0\Access\Security - Level set to
#00000001

and

HKEY_LOCAL_MACINE\Microsoft\Jet\4.0\Engines - SandBoxMode set to #00000002

BW
 
T

Tim Ferguson

I would like to open an Access database from Excel.

To do what?

If you want to access the data, then it's quite easy to read the mdb
directly:

set dbe = CreateObject("DAO.DBEngine")
set db = dbe.OpenDatabase(myPath, False, False)

' actually, you'll have to check the values of the constants
set rs = db.OpenRecordset(mySQL, dbOpenSnapshot, dbForwardOnly)

ThisWorkbook.Cells(12, 45).Text = rs("MyField").Value

db.Close
set dbe = Nothing

Easy. If you think you really need the whole Access GUI open, then you'll
need to use Shell(). But Excel has such a rich UI anyway, that I would
guess that Access is redundant.

Hope that helps




Tim F
 

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