What's wrong with this codes?

G

Guest

Why can't i run application from VB or from Command button? None of these
attempts are working:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

Dim stAppName As String

stAppName = "I:\Corporate\Credit\LOTUS\COLLECTI\ACCESS\ddrcath.mdb"
Call Shell(stAppName, 1)

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub


or another one:
Private Sub runCA_Click()

Dim FilePath As String

FilePath = "I:\Corporate\Credit\LOTUS\COLLECTI\ACCESS\ddrcath.mdb"
Application.FollowHyperlink FilePath


End Sub

Please, can somebody help? Thank you.
 
G

Guest

Hi Juli,
actually the shell command run an executable program and an mdb isn't.
If you want to run an mdb with the shell command you must provide the path
of msaccess.exe followed by the mdb you wanna open.
assuming msaccess resides in C:\Program Files\Microsoft Office\Office

e.g. stAppName = "C:\Program Files\Microsoft Office\Office\msaccess.exe
I:\Corporate\Credit\LOTUS\COLLECTI\ACCESS\ddrcath.mdb"
Call Shell(stAppName, 1)

HTH Paolo
 
G

Guest

I tried it, but no success. I don't what I'm doing wrong but it still gives
me an error: User-defined type not defined. Is there anything else i can try?
Thank you.
 
D

Douglas J. Steele

Actually, because of the embedded spaces in the paths, you need quotes
around at least the path to msaccess.exe:

stAppName = """C:\Program Files\Microsoft Office\Office\msaccess.exe""" & _
" ""I:\Corporate\Credit\LOTUS\COLLECTI\ACCESS\ddrcath.mdb"""
Call Shell(stAppName, 1)

(The extra quotes around the path to the mdb file aren't strictly necessary,
but there's nothing wrong with including them.)
 
G

Guest

Alleluia!! It works, thank you.

Douglas J. Steele said:
Actually, because of the embedded spaces in the paths, you need quotes
around at least the path to msaccess.exe:

stAppName = """C:\Program Files\Microsoft Office\Office\msaccess.exe""" & _
" ""I:\Corporate\Credit\LOTUS\COLLECTI\ACCESS\ddrcath.mdb"""
Call Shell(stAppName, 1)

(The extra quotes around the path to the mdb file aren't strictly necessary,
but there's nothing wrong with including them.)
 

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