Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word document 1

Status
Not open for further replies.

jjinx

Programmer
Oct 6, 2002
12
US
I am having trouble opening a word document from my application. My Code is as follows:

String execProg =
"C:\\Program Files\\MicorsoftOffice\\winword.exe";

String filePath =
"C:\\Documents and settings\\Owner\\My Documents\\my.doc";

try{
Runtime.getRuntime().exec(execProg + " " + filePath);
}catch(IOException ioe){}


For some reason the winWord program opens fine but when it tries to open the file I get an error. It seems that the file path is getting parsed at the spaces and the whole file path is not getting used. The error is get is

"File c:\Documents.doc is not a valid or the path is wrong"

Any suggesttions?

 
You could try escaping quotes around the dir string :

String filePath = "\"C:\\Documents and settings\\Owner\\My Documents\\my.doc\"";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top