Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Runtime load.exec()

Posted on 2006-06-27
3
Medium Priority
?
742 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:mgcIT
3 Comments
 
LVL 14

Accepted Solution

by:
hoomanv earned 2000 total points
ID: 16995815
try
exec(new String[] {"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE", sFileName})
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16995817
Try


load.exec("'C:/PROGRA~1/MICROS~1/OFFICE11/EXCEL.EXE "+ "\"" + sFileName + "\"");
0
 
LVL 18

Author Comment

by:mgcIT
ID: 16996036
thanks... this worked
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question