Solved

Runtime load.exec()

Posted on 2006-06-27
3
738 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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.

729 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