Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make the Shell function work in MS Access 2002/3

Status
Not open for further replies.

pdeman

Programmer
Feb 17, 2010
39
0
0
GB
Hello,

I am using Shell to execute files on the click of an Access button on a form. In the code below Me.filename is the value from a control on the form which is the file name and extension. It is generated and saved in the same folder as the mdb file so CurrentProject.Path completes the full path name.

A major problem I have is that this will open the vbscript file msgbox.vbs
Shell "cscript ""C:\Documents and Settings\mypc\\msgbox.vbs"""

But I need to replace the path name with the variable file like below and just can’t get it to work.

Dim file As String
file = CurrentProject.Path & "\" & Me.filename
Call Shell("cscript.exe " & file, vbNormalFocus)

Any help will be much appreciated.
 
Call Shell("cscript.exe " & Chr(34) & file & Chr(34), vbNormalFocus)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Excellent… worked a treat.
Thank you very much for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top