• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

open up a word document with Ms Word

From Java, it is very easy to open up another program (thanks to Venci75). But what happen if open another program with its own file?

For example, if i want to open up a document file (.doc) with Ms Word from java, what should be the code look like?
0
Heliumyap
Asked:
Heliumyap
  • 4
  • 2
1 Solution
 
Venci75Commented:
try this:

Runtime.getRuntime().exec("cmd /c start c:/temp/kiki.doc");
0
 
Venci75Commented:
I mean:
Runtime.getRuntime().exec("cmd /c start c:/...<the path to your document>");
0
 
HeliumyapAuthor Commented:
Wow! it work! But what does "cmd /c start" mean? Could you explain abit?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
HeliumyapAuthor Commented:
does cmd means the command in dos prompt?
0
 
Venci75Commented:
this actually is a thrick. This starts the command promt. /c means that the commands after that will be executed and after that the command prompt will be closed. Now I am actually looking for a better way - that doesn't show the command promt, but with no success til now
0
 
Venci75Commented:
aha - I found it:
Runtime.getRuntime().exec("explorer c:\\temp\\my_doc.doc");

this force the windows explorer to find the application for this document, and open the document with it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now