VBScript – Embed quotes in strings

SCENARIO

Hi,

[]...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.

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 can't find the file and  Number 3) says that it cannot be accessed, that it may be read-only.  

What am I doing wrong???

  • WScript.Run "Excel.exe "C:\testte~1\TESTTE~1.xls"",1,True
  • WScript.Run "Excel.exe "\\testte~1\TESTTE~1.xls"",1,True
  • WScript.Run "Excel.exe "file:///\\testte~1\TESTTE~1.xls"",1,True
SOLUTION

Have you tried simply using:

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:

s = "This is a ""test"" Bill."

Gives s the value:

This is a "test" Bill.

While:

s = "This is a test ""Bill."""

Gives s the value:

This is a test "Bill."
SOURCE

LINK

LANGUAGE
ENGLISH