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!

Using WScript.Run "Excel.exe ... Excel cant find filename with spaces

Status
Not open for further replies.

oltran

Technical User
Dec 26, 2002
19
US
Hi,

This may not be the correct place to ask but I don't know where else to post this...I am tring to figure out why excel is not able to find a file with spaces when it is placed on an intranet server. I converted the filename/path to the MS DOS format and it runs fine locally (from the C:\) but when I try the same thing on the intranet server excel cant find the file.

I am using the correct MS-DOS name for the file because I rightclick on the file and go to properties to get the DOS filename in each folder (I know the same long filename may have a different DOS name when in different folders).

Here is the long name: \test test\test test.xls, I tried it in the commands below. Number 1) runs fine, number 2) is the one where excel cant find the file and number 3) says that it cannot be accessed, that it may be read-only.

What am I doing wrong???

1) WScript.Run "Excel.exe "C:\testte~1\TESTTE~1.xls"",1,True

2) WScript.Run "Excel.exe "\\testte~1\TESTTE~1.xls"",1,True

3) WScript.Run "Excel.exe "file:///\\testte~1\TESTTE~1.xls"",1,True

many thanks!
Jason
 
Have you tried simply using:
Code:
WScript.Run "Excel.exe ""c:\test test\test test.xls""",1,True
When you want to embed quotes in a VBScript string, you double-up on them (a quote "escapes" a quote that follows it immediately). For example:
Code:
s = "This is a ""test"" Bill."
Gives s the value:
Code:
This is a "test" Bill.
While:
Code:
s = "This is a test ""Bill."""
Gives s the value:
Code:
This is a test "Bill."
Maybe that's all that tripped you up here. You have an unbalanced quote situation in the examples you showed. Did that script really run that way? Looks like a syntax error.
 
thanks dilettante! thats where my problem was! I read about using quotes for the filepath to be able to include spaces but when I tried it, it failed. but it didn't dawn on me about the escape characters.

Thanks!
Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top