Solved

Runtime load.exec()

Posted on 2006-06-27
3
736 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 500 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 99
Java JRE greater than 1.6 5 63
jar file executable 12 52
ejb on wildfly 5 20
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

825 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