VB code to launch and run an ACCESS DB

jtalbott
jtalbott used Ask the Experts™
on
I'm trying to get a Macro to run to open an Access 2007 DB which is located on a shared drive S.  

I get this error message " There is no script engine for this file extension".mde"

This is the code:

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)

REM This line calls the macro subroutine
subSub1_
sub subSub1_()

Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "WScript.exe S:AcsData\Disco.mde", 1, False

end sub
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Awarded 2010
Top Expert 2013
Commented:
That's because you are trying to send the database as a parameter to WScript. For a quick fix try calling the Access file directly:
wshShell.Run "S:AcsData\Disco.mde", 1, False

The other (and better) option is to set a reference to the Access library in your project and use something like this:
    Dim objAcc As Access.Application
    Set objAcc = New Access.Application
    objAcc.Visible = True
    objAcc.OpenCurrentDatabase "S:AcsData\Disco.mde"
    objAcc.DoCmd.RunMacro ("YourMacro")

Open in new window

Top Expert 2011

Commented:
To use Shell you must include the path to the MSACCESS.EXE

wshShell.Run "C:\<<path to EXE>>\MSAcess.exe WScript.exe S:AcsData\Disco.mde", 1, False
Top Expert 2011

Commented:
Opps...

Try this:

wshShell.Run "C:\<<path to EXE>>\MSAcess.exe S:AcsData\Disco.mde", 1, False

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial