aspose file tools*
The moose likes Beginning Java and the fly likes Loading a word file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Loading a word file" Watch "Loading a word file" New topic
Author

Loading a word file

Lloyd Jenkins
Greenhorn

Joined: Apr 17, 2002
Posts: 11
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

Joined: Sep 29, 2000
Posts: 8521
Sure
Runtime.getRuntime().exec("winword.exe myfile.doc");
Should work.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Lloyd Jenkins
Greenhorn

Joined: Apr 17, 2002
Posts: 11
Cindy, you are a Goddess
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Gee - a promotion!!
Lloyd Jenkins
Greenhorn

Joined: Apr 17, 2002
Posts: 11
haha! You deserve it. You've given me the only positive out of my imminently-deadlined assignment
Lloyd Jenkins
Greenhorn

Joined: Apr 17, 2002
Posts: 11
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

Joined: Jul 11, 2001
Posts: 15300
    
    6


That will work.
[ April 18, 2002: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Lloyd Jenkins
Greenhorn

Joined: Apr 17, 2002
Posts: 11
You guys rule
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading a word file