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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell Function not working

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
I am trying to open a txt file in Wordpad using the following code.
Dim appid
Dim File1 as String
File1 = "C:\Program Files\Files\File.txt"

appid = Shell(strWordpadLoc & " " & File1, 1)


strWordpadLoc is a public construct set as
Public Const strWordpadLoc = "C:\Program Files\Windows NT\Accessories\Wordpad.exe"
When this code runs I get an error "C:\Program Cannot find this file. Please verify correct file and path name."
The file does exist and if I open Wordpad independently I can open File1.txt. Any thoughts as to why this is not working


 
Try either this:
appid = Shell(Chr(34) & strWordpadLoc & Chr(34) & " " & Chr(34) & File1 & Chr(34), 1)
Or this:
appid = Shell("""" & strWordpadLoc & """ """ & File1 & """", 1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The second option works perfectly! Thanks so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top