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

Opening an application by passing a file name

Status
Not open for further replies.

kurtmo5

Programmer
Jul 16, 2004
18
US
Below is my code. It works fine when I pass a file in without any spaces in the name; however, when a filename has a space in it, it quits reading the filename at the space and never executes. I could I pass the filename in so it reads the space as part of the filename. It is passed using a Resonse.write statement in C#.

Sub openDocument(file)
Set oShell = CreateObject("Wscript.Shell")
oShell.run file
End Sub
 
Have you tried to replace this:
oShell.run file
By this:
oShell.Run Chr(34) & file & Chr(34)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PH, it works beautifully. Just wondering what the Chr(34) & actually does. Also I am running other calls that run this sub that pass file names with 0 spaces in them. Will this effect those filenames opening at all? thanks again!
 
It will not affect names without spaces in them. All it does is surround the file with double quotes (ASCII character 34)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top