• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading a word file

 
Lloyd Jenkins
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I want to load a .doc file when i click on an option in a menubar I've created. Doesn't have to be loaded into an output window I create or anything; just simply load the .doc file up in, say, Word.
Is there any way I can do that? Sounds like a simple one-line bit of code to go in the function, but probably not
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure
Runtime.getRuntime().exec("winword.exe myfile.doc");
Should work.
 
Lloyd Jenkins
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cindy, you are a Goddess
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gee - a promotion!!
 
Lloyd Jenkins
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha! You deserve it. You've given me the only positive out of my imminently-deadlined assignment
 
Lloyd Jenkins
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the...
Runtime.getRuntime().exec("winword.exe myfile.doc");
...line that Cindy gave me. I use it inside an 'else if' statement, but it asks for an IOException to be caught.
I've created this exception inside the 'else if' statement (with the line call), but it wants a try call too...which I can't do.
Here's the offending bit of code. Thank you people
--------
public void serviceMenuEvent(MenuItem menuItemObject)
{
..... (previous code)
else if (menuItemObject == vrep)
{
Runtime.getRuntime().exec("winword.exe report.doc");
catch (IOException e)
{
System.err.println(e);
}
}
}
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

That will work.
[ April 18, 2002: Message edited by: Gregg Bolinger ]
 
Lloyd Jenkins
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You guys rule
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic