Solved

Runtime load.exec()

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now