Runtime load.exec()

I have an app that creates an excel file and then opens that excel file when it is finished.  This works fine except when there are spaces in the file name.  For example if I have a file called:

my excel file.xls

I will get 3 error messages from excel when it tries to open the program.  It see's each word (my, excel, file) as a separate file and of course can't find them.  Here is my code:

load.exec("C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE "+sFileName);

I have also tried:
load.exec("'C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE "+sFileName+"'");

but this throws an exception.

The obvious answer to this is to not put any spaces in the file name but that will not work for my requirements.

thanks
LVL 18
mgcITAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
hoomanvConnect With a Mentor Commented:
try
exec(new String[] {"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE", sFileName})
0
 
CEHJCommented:
Try


load.exec("'C:/PROGRA~1/MICROS~1/OFFICE11/EXCEL.EXE "+ "\"" + sFileName + "\"");
0
 
mgcITAuthor Commented:
thanks... this worked
0
All Courses

From novice to tech pro — start learning today.