1

I am trying to open an Access 2003 .mde file using Excel VBA.

So far I have tried:

Shell ("cscript "C:\User\Folder\Access Database.mde""), vbHide

Now this works perfect to open a .vbs file and the code runs to open the .mde file but does not actually open the database.

I also tried the following:

        strdb = "C:\User\Folder\Access Database.mde"
        Set AccessApp = CreateObject("Access.Application")
            AccessApp.Visible = True
                AccessApp.OpenCurrentDatabase.strdb
                    AccessApp.DoCmd.OpenForm "frmsysteminformation"
                        Set AccessApp= Nothing

I found this online but it gives me a debug error highlight the line:

Set AccessApp = CreateObject("Access.Application")

Thanks

Edit My company seems to have disabled some of the features as

CreateObject("Outlook.Application")

also doesn't work. Is there a way to run this through cscript?

Doog_Dooger
  • 127
  • 8
  • Code you provided works on both Excel-Access 2003 and Excel-Access 2010 with .mde file. Mind dot in `AccessApp.OpenCurrentDatabase strdb`. With which version of Access you are trying to open the file? What error do you get on line `Set AccessApp = CreateObject("Access.Application")`? – hstdggsdtgsdafssarf456 Aug 22 '16 at 16:21
  • I get run-time error 429: ActiveX component can't create object. – Doog_Dooger Aug 22 '16 at 16:25
  • I dont know. Maybe its similar to [this](http://stackoverflow.com/questions/4213496/how-do-i-resolve-run-time-error-429-activex-component-cant-create-object). With the difference being not msrdo20.dll, but some dao dll file. – hstdggsdtgsdafssarf456 Aug 22 '16 at 16:52
  • Thanks. I think my company has disable some of the features as `Create.Object("Outlook.Application")` doesn't work either. Do you know of a way to get it to open through Shell? – Doog_Dooger Aug 22 '16 at 17:33

1 Answers1

1

Just in case anyone stumbles across this same issue I managed to work it out:

Dim sAcc
Dim sFrontEnd
Dim sSec
Dim sUser
Dim objShellDb
Dim sComTxt

'Script Configuration Variable
'*******************************************************************************
'Specify the Fullpath and filename of the msaccess executable
sAcc = "C:\Program Files\Microsoft Office\Office11\MSACCESS.EXE"
'Specify the Fullpath and filename of the database to launch
sFrontEnd = "C:\users\file location\Database to open.mde"

Set objShellDb = CreateObject("WScript.Shell")
'Build the command to launch the database
sComTxt = Chr(34) & sAcc & Chr(34) & " " & Chr(34) & sFrontEnd & Chr(34)

objShellDb.Run sComTxt 'Launch the database

End Sub
Doog_Dooger
  • 127
  • 8