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!

Can't start the files in folder "C:\My Documents\"

Status
Not open for further replies.

softlover

Programmer
Apr 4, 2002
88
0
0
CN
I want to execute any file in the folder "C:\My Documents\" by the codes below.
Call Shell(Environ("COMSPEC") & " /C START C:\My Documents\" & FileName, vbHide)
But failed with following message:
System can't find the object "C:\My".
I think the blank character in the "C:\My Documents\" string caused the problem. Anyone has good ideas, Please tell me. TIA.
 
You may try this:
Call Shell(Environ("COMSPEC") & " /C START [!]"& Chr(34) & "[/!]C:\My Documents\" & FileName [!]& Chr(34)[/!], vbHide)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Maybe (?):
Call Shell(Environ("COMSPEC /C Start") & Chr(34) & "C:\Documents and settings\fionnuala\DirThis.bat" & Chr(34))
 
The codes below can't work.
Call Shell(Environ("COMSPEC /C Start") & Chr(34) & "C:\Documents and settings\fionnuala\DirThis.bat" & Chr(34))

After run the codes by PHV.
Call Shell(Environ("COMSPEC") & " /C START "& Chr(34) & "C:\My Documents\" & FileName & Chr(34))
The fileName need execute can't opened and only a new form opened.
 
The problem submitted at 1 Aug 06 still exist. I create a EXCEL file "AAA.XLS" in folder "C:\My Documents" and want to execute it by ACCESS codes. I use codes:
Call Shell(Environ("COMSPEC") & " /C START C:\My Documents\AAA.XLS", vbHide)
But failed.
 
softlover,
Why not [tt]Application.FollowHyperlink("C:\My Documents\" & FileName)[/tt]?

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thanks to CautionMP, But the codes you writed can't work well. The system prompt that "can't find the named file.
 
softlover,
Assuming [tt]C:\My Documents\AAA.XLS[/tt] exists on your computer does this work?
[tt]Application.FollowHyperlink("C:\My Documents\AAA.XLS")[/tt]

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Just now, I find the correct codes:
Call Shell(Environ("COMSPEC") & " /C START EXCEL C:\My Documents\AAA.XLS", vbHide)
Thanks to all.
 
How are ya softlover . . .

Glad ya got it working!

Note: you'll be OK as long as there's [blue]no spaces in your path or filename![/blue] If this becomes a problem the following will take care of path & file with/without spaces:
Code:
[blue]   Call Shell(Environ("COMSPEC") & " /C START " & """" & "C:\My Documents\" & FileName & """", vbHide)[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top