Open Access File From Excel

Todd Bardoni

Well-known Member
Joined
Aug 29, 2002
Messages
3,042
The following code "works", but when Access opens and tries to swith to the specified file I get a message from Access that says something about it does not recognize the commandline. Any ideas?

Code:
Sub AccessDatabase_Execute()
    Dim taskID As Double, myPath As String, myFile As String
    On Error GoTo errorhandler
    myPath = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
    myFile = ThisWorkbook.path & "\AMOS Item Master.mdb"
    taskID = Shell(myPath + " " + myFile, vbNormalFocus)
    Exit Sub
errorhandler:
    MsgBox "Cannot find the exe file to open this program.", vbCritical
End Sub
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Todd Bardoni

Well-known Member
Joined
Aug 29, 2002
Messages
3,042
Got it to work. I had to take out the spaces " " in the .mdb file name.
 

Watch MrExcel Video

Forum statistics

Threads
1,111,598
Messages
5,541,163
Members
410,543
Latest member
ExcelGlenn
Top