Opening MS-Word in JAva
I want to open and use MS-Word in Java, who can help, and have already done this.
Thanks
Shujah
Hi,
I am, in process of Developing Internet based Application, in which loged in User should have the posibility to use (MS-Word, MS-Outlook), (MS-Word for creating new Documents, MS-Outlook should be used for EMail, and Calender options) all the Applications (Word, Outlook) are installed on Database server and not on the client (local), is there any way to solve my problem, iy yes please let me know,
Thanks
Shujah
Similar Messages
-
Open a word document from a Java Application
Hi,
Can I open a word document from a java GUI apllication and point to a bokkmark automatically in the word document when opened.See this thread:
http://forum.java.sun.com/thread.jspa?threadID=228332&messageID=810684 -
How To Open Word In Java Application
Hello
How To Open Ms-Word Or Ms-Excel Or Any Other Format In Java Application
According To Their Own ForMatThe best is to know which program you like to execute. Make those many strings available. Suppose you like to execute M$ Word and M$ Excel. Now do like this..
String word = ""; // null
String excel = ""; //null
/* In the File Class you can find out the methods that can search these files and return thier
absolute and relative paths. Save those paths in uppe String(s) word and excel and place them in
runtime.exec( word/excel)...etc. Place this code before a tolbar button and click that..*/ -
Opening a Word Document with a Java program in Windows
When running a Java program in Windows, is it possible to have a button where when it is clicked it will open a Word document?
If so, is it hard and can someone tell me how to do it??
Thankstry this instead of Excel.exe you have to use Word.exe
1. Declare your button
JButton butexlcom = new JButton("Carnet Offre");
butexlcom.addActionListener( new ButExlCommercial(msgout));
butexlcom.setBounds(215,510,110,30);
c.add( butexlcom );
2. run your word document.
class ButExlCommercial implements ActionListener {
private JTextArea msgout;
public ButExlCommercial( JTextArea msg) {
msgout = msg;
public void actionPerformed( ActionEvent e ) {
try {
Runtime.getRuntime().exec("c:\\Program Files\\Microsoft Office\\Office\\Excel.exe NameWordDocument");
catch(Exception en) {
msgout.append( "\n*** PROBLEME WORD ***\n" );
} -
Opening a word document in Java
HI
I am new to java. I am trying to open a word document when user press the button. I just want to open the document that exists on my computer. I have tried using exec() method of Runtime class. But I was not succeed. Here the code that I have used.
public void actionPerformed(ActionEvent ae) {
String str = ae.getActionCommand();
if(str.equals("Search")){
Runtime r = Runtime.getRuntime();
Process p = null;
try{
p = r.exec("C:\\Program Files\\Microsoft Office\\OFFICE11\\WINWORD.exe C:\\Resume\\coverletter.doc");
}catch (IOException e){
System.out.println("Error");
repaint();
Here "Search" is th name of Button.
So if anyone have a solution please help me regarding to this.
Thank youUse java.awt.Desktop (available since Java 6), it provides a .open() method that will open any file with the users associated application (so no dangerous hardcoding of application paths necessary).
If you insist on using Runtime.exec, then you must read [When Runtime.exec() wont|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html]. -
Hi all,
Can we open word from java.
It is possible from VB to do it, bit is it possible from Java.
Thanks in advance for your help.
Best regards.
Saadi MONLAProbably have to do it using Runtime.exec() and call the word exe in the seperate process.
Note that word will be opened in a seperate OS thread and you will not be able to refer to it from your Java Application. -
Opening a word file in MS Office Word software window through Java code
I want to open a word file in MS Office Word software window through Java code.
Is it possible ? If possible then please let me now how can I do it.
BhoopenderThanks for replying.
I tried the following code -
public class OpenFileWithItsExt
public static void main(String[] args) throws java.io.IOException
Runtime.getRuntime().exec("a.doc");
and it gets compiled successfully, but on running outputs as -
Exception in thread "main" java.io.IOException: CreateProcess: a.doc error=193
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at OpenFileWithItsExt.main(OpenFileWithItsExt.java:5)
My file is in the pesent working directoty.
Please solve my problem.
Thanks -
Open/save word document in jsp
I can open a word document in jsp but i don't know how to save and close it to where i want again inside same jsp.
I find a code that do thing i want to do but it was written in vb script.
How can i convert vb code below to java / jsp?
Dim wrdApp As Word.Application
MyStr = Format(dtMyDate, "mmm dd, yyyy") & ".doc"
Set wrdApp = New Word.Application 'released first resources
With wrdApp
.Documents.Add "normal.dot", , , True
strPatientName = txtName.Text
strFileName = "c:\MJCC\Lab\" & strPatientName & "_" & MyStr
.ActiveDocument.SaveAs strFileName
.ActiveDocument.Close
.Quit
End With
Set wrdDoc =Nothing<%@ page contentType="application/vnd.ms-excel" language="java"%>
<meta http-equiv="Content-Type" content="application/vnd.ms-excel; charset=iso-8859-1">
by using this 2 codes, when i run this page, it will pop up a box for me to save the jsp file..
i'm able to save it in xls / csv format...
so, mayb you can try change the ms-excel to ms-word or something else..
hope this is useful... -
Problem in opening MS Word doc from CRM back-end.
Hi All:
I have a MS Word document stored in my CRM system which opens by passing a transaction number as input. When we try to preview the word
doc it opens properly from back-end.
But the real problem exists when i'm trying to open it from my web-dynpro thru java, it never opens in a correct format(i mean it never opens at all). When I stored it in local machine to open it from notepad, i could see all the junk data along with original text.
If any one have done this successfully before, plz do let me know the way or send me the code sample to read word from webdynpro java. I've implemented with couple of options which didnt worked.
Munna_SAPHi All:
I've solved it by my own and it opens the word document properly.
Solution: I didnt looked at the r\3 end that how it was coded, i've changed my code in java to meet the requirement.
Tnx,
Munna_SAP -
hi all
I have a prob with my code
the problem is by using the FileChooser like
file = fileChooser.getSelectedFile();
I have the file name but how can i open that file e.g. if file is word document then that file should open in word , if that file is HTML file then open in IE , and other files as well.
is there any way to open a file
plz help me
Thanx
Regards
Satinderjitveer ji, try this code on your pc if you can. Click the print button and see that happens. thanx yuvraj:
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
//import com.sun.java.swing.*;
import javax.swing.*;
public class ComponentPrinterFrame
extends JFrame
implements Printable {
public static void main(String[] args) {
ComponentPrinterFrame cpf = new ComponentPrinterFrame();
cpf.setVisible(true);
public ComponentPrinterFrame() {
super("ComponentPrinterFrame v1.0");
createUI();
protected void createUI() {
JPanel panel = new JPanel();
JButton printButton = new JButton("Print");
panel.add(printButton);
panel.add(new JList(new Object[] { "One", "Two", "Three" }));
panel.add(new JButton("Push me"));
panel.add(new JCheckBox("Chess", true));
panel.add(new JComboBox(new Object[] { "Eins", "Zwei", "Drei" }));
printButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(ComponentPrinterFrame.this);
if (pj.printDialog()) {
try { pj.print(); }
catch (PrinterException pe) {
System.out.println(pe);
setContentPane(panel);
setSize(400, 400);
// Center.
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
int x = (screenSize.width - frameSize.width) / 2;
int y = (screenSize.height - frameSize.height) / 2;
setLocation(x, y);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
public int print(Graphics g, PageFormat pf, int pageIndex) {
if (pageIndex != 0) return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D)g;
g2.translate(pf.getImageableX(), pf.getImageableY());
getContentPane().paint(g2);
return PAGE_EXISTS; -
How can I open a word-document in word?
I want to have a link in my java-program to a word-document, but I don't know how to open the document in word from java.
If you are using windows and word is set up as the associated program for doc files, you could use a runtime process to open it. To find the correct syntax, try to open the document through the command line and then use that command.
-
Opening a word document for editing with webdav
I'm not sure if this is the correct place for this question..
I am attempting to open a word document, which resides in a webdav folder from web app. I need IE to start word and open the original document from the webdav folder and allow the user to make changes to the document and save it back to the webserver.
Wep app this http://www.javatalks.ru/go.php?uri=http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/WebdavServlet.java
I've got it to open the document but it seemed to have copied the document to my temporary internet files folder and opened the copy from there. The original file name is "test.doc" but the opened temprary file is "test[1].doc" and so on. How can I get it to open the original document for editing?
Any help would be appreciated..Not sure about payment options but you can check for yourself at http://success.adobe.com/en/na/sem/products/acrobat/feature.html
-
Hey
I got a question for a program that im programming im trying to program a button
that opens a word File the moment u click on the button. Anychance any of u know how to realize this ?
Please let me know.
Stevenprivate void MbriefActionPerformed(java.awt.event.ActionEvent evt) {
Process process = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler c:\test.doc");
} I basicly get the next error message
with this code while compiling
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Administrator\Bureaublad\I-1\Last moment\2ProjectSportivo\build\classes
C:\Documents and Settings\Administrator\Bureaublad\I-1\Last moment\2ProjectSportivo\src\projectsportivo\Overzichten.java:205: unreported exception java.io.IOException; must be caught or declared to be thrown
Process process = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler c:\test.doc");
*1 error*
BUILD FAILED (total time: 0 seconds) -
Invoking Microsoft Word from Java code
I want to invoke Microsoft word from Java code. How can i do this plz ............... Help
do something along these lines.... here is an example with notepad
create a .bat file with the commmand in to run notepad for example
notpad c:\test.txtthis command calls notepad and passes it the argument C:\test.txt which is the file and it's location, that I want to open.
The Java program
import java.util.*;
import java.io.*;
public class Run
public static void main(String args[])
try
//the name of the batch file with your commands in
String command ="runprog.bat";
//get the runtime
Runtime rt = Runtime.getRuntime();
//run the bat file
Process proc = rt.exec(command);
//wait for the program to exit i.e notepad then get the return code
int exitVal = proc.waitFor();
//print out the exit value
System.out.println(2THe Process exit value is: " + exitVal);
catch(Throwable t)
t.printStackTrace();
}have a look at this
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
and this
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html -
Opening browser window from Java Swing
Hi
I am trying to open
1) a word document on the click of a button from a Java-Swing based application running only on windows based system.
Currently the code uses 'rundll' and calls 'a.doc'
it requires that the application be installed and run only from a specific location in the windows' system.
i would like to modify the code in one of the following ways
1) open the word doc irrespective of its location and that of the executable jar which is trying to open this file
2) upload the word document to a website and direct the application to open that webpage on button click, etc
i believe that the latter may be simple but i do not have any idea about how to go about it
i would appreciate some guidance about it.Hi,
I was trying to run the code, for embeding the mozilla web browser in my java application which is running at linux fedoracore2. I set all the environment variables, like MOZILLA_FIVE_HOME and LD_LIBRARY_PATH. I can able to compile successfully but if i run the code, i got the error message like this
Exception in thread "main" java.lang.Error: Untranslated exception
at sun.nio.ch.Net.translateToSocketException(Net.java:63)
at sun.nio.ch.Net.translateException(Net.java:79)
at sun.nio.ch.Net.translateException(Net.java:85)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:61)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
at org.jdesktop.jdic.browser.MsgClient.<init>(Unknown Source)
at org.jdesktop.jdic.browser.NativeEventThread.<init>(Unknown Source)
at org.jdesktop.jdic.browser.WebBrowser.<clinit>(Unknown Source)
at IEInJava.main(IEInJava.java:8)
Caused by: java.net.SocketException: Unresolved address
at sun.nio.ch.Net.translateToSocketException(Net.java:55)
... 8 more
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:30)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:115)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
... 5 more
Thats the error.
I could not find out, where i had made the mistake, i need help. Any suggestion and comments are most welcome. Thanks.
Maybe you are looking for
-
How to pass a col of pl/sql tab to a parametrized cursor?
Hi, I'm getting this error constantly: Error on line 1 declare j number :=1; cursor f ORA-06550: line 9, column 20: PLS-00103: Encountered the symbol "TABLE" when expecting one of the following: constant exception <an identifier> <a double-quoted del
-
Hight temperature, low fans speed. A problem_
I have a problem with OS 10.8.3 on macbook pro retina 15. When temperature increases, above 75°C, I notice no change in fans speed, not increase. Only with a external program (the smcfan control) is possible to increase speed and decrease the tempera
-
BED, Ecess, HSEcess is Zero in MIGO
Hi buddies, I am testing TAXINN procedure. I have maintained all the customization for TAXINN. Maintained all excise relavent details in J1ID. Maintained tax code in FTXP and contidion records in FV11. Created PO with the tax code and the values of B
-
Why can't I see the pen tool?
Hi - I'm using the latest Adobe Premiere Pro but when applying a mask I have the option of the ellipse or the 4 point polygon, but no pen tool...any idea why?
-
i need to delete this email acct off my phone but cant because i did it from the link, the information that i have in is wrong. What to do?