About create a Word file with Jacob

Hello!
I want to create a new MSWord document with Jacob. All the examples that I have seen are for MSExcel and me do not serve. How I can create this document, insert text and images, the application to record and to close it from Java?
This it is the code that I use to open the application, but it trumps me when I try to create a new document.
public class DispatchTest {
public static void main(String[] args) {
ActiveXComponent dc = new ActiveXComponent ("Word.Application");
try {
dc.setProperty("Visible", new Variant(true));
Object documents = dc.getProperty("Documents").toDispatch();
Object document = Dispatch.get(documents, "Add").toDispatch();
} catch (Exception e) {
e.printStackTrace();
Thank you very much!

Hi,
Here is the code which is used to open an Word or Acrobat Reader.
import java.lang.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Demo1 extends JFrame implements ActionListener {
JMenuBar mbar = new JMenuBar();
JMenu file = new JMenu("File");
JMenuItem n_pad = new JMenuItem("Notepad");
JSeparator sep = new JSeparator();
JMenuItem m_word= new JMenuItem("Ms Word");
JMenuItem a_bat = new JMenuItem("Acrobat Reader");
public Demo1(){
setUpMenuBar();
public void setUpMenuBar(){
file.add(n_pad);
file.add(m_word);
file.add(sep);
file.add(a_bat);
mbar.add(file);
setJMenuBar(mbar);
n_pad.addActionListener(this);
m_word.addActionListener(this);
a_bat.addActionListener(this);
public void display(ActionEvent evt1){
Runtime r= Runtime.getRuntime();
Process p=null;
try{
if(evt1.getSource()==n_pad){
p=r.exec("notepad.exe"+" "+"c \\javafiles\\listit.java");
p.waitFor();
else if(evt1.getSource()==m_word){
// p=r.exec
("rundll32"+" "+"url.dll,FileProtocolHandler"+" "+"Winword.exe"+" "+"file /
/c \\newcorpus\\index.htm");
//p=r.exec
("rundll32"+" "+"url.dll,FileProtocolHandler"+" "+"Winword.exe"+" "+"c \\ja
vafiles\\listit.java");
p=r.exec
("rundll32"+" "+"url.dll,FileProtocolHandler"+" "+"Winword.exe");
p.waitFor();
else if(evt1.getSource() == a_bat){
//p=r.exec
p=r.exec("rundll32"+" "+"url.dll,FileProtocolHandler"+" "+strFile);
//strFile gives the complete path where it is saved
/* ("rundll32"+" "+"url.dll,FileProtocolHandler"+" "+"Acrord32.exe 'c \\javaf
iles\\jspintro.pdf'");
p=r.exec
("rundll32"+" "+"url.dll,FileProtocolHandler"+" "+"Acrord32.exe");
p.waitFor();
}catch(Exception e){e.printStackTrace();}
public void actionPerformed(ActionEvent evt){
display(evt);
public static void main(String args[]){
Demo1 md=new Demo1();
md.setVisible(true);
md.setSize(200,300);
I hope this will help you.
Thanks
Bakrudeen
Technical Support Engineer
Sun MicroSystems Inc, India

Similar Messages

  • Converting Word Files with Backgrounds

    I've created a Word file with a background by going to Format/Theme and choosing Slate. When I convert the file to .pdf, it fails to capture the background. Does anyone know how to accomplish this? It is an integral part of the document and I need it to transfer to the pdf as well.
    Any help would be greatly appreciated.

    No, apparently the background does not print either. That is a terrible shame. So, it is not object data at all, and thus Acrobat won't print it. I'm left with creating a background image behind text then in order to make that work.
    If anyone else has any ideas, it would be of great help.

  • I am trying to create a print ready PDF from a word file with unacceptable results.

    I am trying to create a print ready PDF from a word file with unacceptable results.
    The word file has a trim size of 6” x 9”. It has been set to mirror margins with the inner, top and bottom margins set to 0.75”, the outer margin is set to 0.5” and the gutter to 0.14”.
    It doesn’t matter if I create the PDF from inside Word, or open Acrobat Pro 11.0.9 and click Create From File, while the resulting document size is correct and the odd numbered pages reflect the correct margins, the even numbered pages do not. This results in some text near the outer margin, as well as the page numbers being omitted.
    Does anyone know how to correct this?
    I just noticed that some of the odd numbered pages' text is also cropped. Apparently Acrobat is refusing to set side margins to smaller than 1" (@ 3cm).

    I'm away from my printer, so I'll try it later. Even so, the proposed test is irrelevant. I operate a small publishing house and am trying to upload certain novels to Ingram, the largest book distributor in the world. The specifications I've set are the specifications they've asked for. Since they've said that the results I'm obtaining are unacceptable, and since they demand submission in PDF form, this renders Acrobat Pro for Mac completely unacceptable for anyone in the publication industry. As far as I can tell, Adobe has a serious bug here that it needs to fix—and at once.

  • Generally when creating a Word file from either a Mac or Win7 pc and opening it on two different machines (either one first) it always prompts that the file is open and will be opened as read only. However opening a CSS file does not prompt that it is alr

    Generally when creating a Word file from either a Mac or Win7 pc and opening it on two different machines (either one first) it always prompts that the file is open and will be opened as read only.
    However opening a CSS file does not prompt that it is already open on or from any machine which is causing code edits to be lost.
    What we found from out testing:
    - The file can be saved from one user to the server and WILL NOT PROMPT on other machines until the saving machine has the Dreamweaver program closed completely
    - The file can be closed and  Dreamweaver minimised to the launch bar but it still will not register on other machines that it has been changed.
    - Also, until the  Dreamweaver program is closed on the machines, it will continue to open it's saved version of the file. 
    Example Scenario:
    - User 1 opens test.css (which is 2000 lines) and adds some code to the end of the file to bring it up to 2500 lines
    - Meanwhile User 2 opens test.css as well (opens as 2000 lines as User 1’s edits have not yet been saved) and adds in code to bring it to 2300 lines
    - User 1 saves his file and closes it - but  Dreamweaver is still open.
    - User 2 also saves his file and leaves  Dreamweaver  open.
    - The server will report the size and last edit of the file the same as User 2 as he was the last person to save it (and if you open from the Win7 Machine it will show as User 2’s 2300 line version)
    - If User 1 then open's the file again (from either the 'recent' in Dreamweaver OR clicking on the file directly in Finder...which version opens.... The version that User 1 saved! Not the true version on the server, but the version that User 1 edited and saved with 2500 lines in it.
    - Same for User 2, he will open 'his' version with 2300 lines in.
    Other information:
    - Files are opened directly from the server
    - Sometimes the users will save incrementally and re-open
    - Most of the time users will save incrementally and keep the files open
    - The users will never not save incrementally and just save when closing the file once finished
    - The users are usually working on the files all day
    - It is always the bottom lines of code that are lost. It could be a case of the two versions being mixed up and cutting off the newly added lines based on the line count (possibly).
    It is as if Dreamweaver is holding a cache of the version locally and then only properly looking back to the server when it has been completely closed. It is very difficult to see how the server is causing such an impact on these files, there are very few logs which are giving any indication to the root cause of the problems.
    Anyone know if this is a known issue?
    Is there a way that there can be a featured implemented on the server that doesn't allow another user to open a file if it is already open on another machine?
    Thanks

    Your server file handling has nothing, and really nothing to do with Adobe software. If files don't get locked for (over-)writing and/or lose connection to the program opening them, then your server is misconfigured. It's as plain and simple and that. Anything from "known file types"/ file associations not being set correctly, MIME types being botched, crooked user privileges and file permissions, missing Mac server extensions, delayed file writing on the server, generic network timeout issues and what have you. Either way, you have written a longwinded post with no real value since you haven't bothered to provide any proper technical info, most notably about the alleged server. Either way, the only way you can "fix" it is by straightening out your server and network configuration, not some magic switch in Adobe's software.
    Mylenium

  • Create a word document with TOC, table,etc

    Hi,
    How to create a word document with Table of content(TOC),header, footer, table, etc?
    Help me with any APIs or examples. I have already tried with POI API, but couldnt create TOC.. So any other api or any solution is available to create complex word document.
    Thank you

    Hi BIJ001,
    Thanks for your valuable suggestion.
    Open standards WordprocessingML format is supports by Microsoft word. It is typical xml format of designing word document. But creating document with TOC,tables, different styles of paragraphs are complex. Using this format, i have created simple docs. I never tried with complex formats like TOC. The generating File should be in ".doc or .docx" format only.
    Hi gimbal2,
    I am parallely looking to find solution in OpenOffice format also. But i never try out ".docx" file format. I will try to look out this option.
    Thanks for the input.
    Edited by: user13735134 on May 24, 2011 6:55 AM

  • How to create a csv file with NCS attributes?

    Hi
    i installed Cisco Prime NCS and trying to perform bulk update of device credentials with csv file.
    How to create a csv file with all required attributes?
    This is part of NCS online help talking about this topic:
    Bulk Update Devices—To update the device credentials in a bulk, select Bulk Update Devices from the Select a command drop-down list. The Bulk Update Devices page appears.You can choose a CSV file.
    Note        The CSV file contains a list of devices to be updated, one device per line. Each line is a comma separated list of device attributes. The first line describes the attributes included. The IP address attribute is mandatory.
    Bellow is test csv file i created but does not work:
    10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    The error i am getting while importing this file:
    Missing mandatory field [ip_address] on header line:10.64.160.31,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    Assistance appreciated.

    It looks like the IP address field is incorrectly set.,
    It should be as follows
    {Device IP},{Device Subnet Mask}, etc etc
    so a practical example of the aboove could be (i dont know if this is completely correct after the IP address / Subnet Mask)
    10.64.160.31,255.255.255.0,v2c,2,10,snmpcomm,ssh,zeus,password,password,enablepwd,enablepwd,60
    below is a link to the documentation
    http://www.cisco.com/en/US/docs/wireless/ncs/1.0/configuration/guide/ctrlcfg.html#wp1840245
    HTH
    Darren

  • Issue of importing MS WORD file with inline images in 5.5 that did not exist in 5

    Briefly, all of the files I created from dropping in MS WORD files with images look exactly the same in ID 5 as they do in WORD.
    When I tried importing the same WORD files in ID 5.5, they look screwed up. For example, in WORD and CS5, the images were perfectly sized and aligned to fit the margins  Then, on exporting to various formats (eg., PDF, EPUB), the program hangs around the 85% completion mark, and I have to manually end the program. I have mixed graphic formats on the images, JPG, GIF, and PNG, if that makes any difference.
    Thanks.
    PS: This input box will not accept hard returns - only manual line breaks. Is that normal?

    I forgot to say that all of the same images in 5.5 are shown in various sizes. Resizing the frames manually, and then clicking on "Fit contents to frame," will of course, correct the problem, but it is frustrating to do.

  • Error when save word file with easy dms

    Hey,
    When I want to save an word file with easy dms I got the following error:
    "An error occured while creating the original attribute for WWI".
    I have no idea why.
    Thanks for your support.
    BR,
    Christoph

    Hi Christoph,
    You need to check the following configurations
    1) Transaction DC20: Whether data carrier has been defined
    2) Transaction DC10: Define document types
    3) Transaction DC30: Define workstation application
    4) Transaction OAC0: Define content repositories
    5) Transaction CSADMIN: Check status of content repository
    Regards,
    Deepak Kori

  • How to create a new file with existing file's resource fork?

    Hello,
    I would like to create a new file that has the resource fork of an existing file. I had though of making a copy of the existing file, seek to the beginning of the copy and write the new data, but for large files, that creates the whole file even when not needed. I currently create the new file with [NSFileManager createFileAtPath: contents: attributes:], but attributes do not include resource fork items, like custom icons, color label, etc.
    [NSURL resourceValuesForKeys] gives a common subset of resource data, like icons and color label, but that's about it. Is there some way to get the resource fork or a copy of the file without getting the whole file?
    Thanks

    What are you trying to do here? While resource forks might still be quasi-supported, you really shouldn't be thinking about them as such. Instead, think in terms of extended attributes. You can use the low-level xattr() functions to get some of that or you can use the new NSURL methods.

  • How to insert a background file in a word file using jacob?

    how to insert a background image file in a existed word file using jacob and set the image as behind text?
    Also, where I can find the documentation for jacob,
    Thx very much.

    Go to http://www.simtel.net/pub/pd/60701.html

  • Create a flat file with multiple characters for enclosures

    Hello,
    we use OWB 11g2 (11.2.02).
    Now we try to create a flat file with multiple characters for enclosures. The manual wrote:
    "Enclosures (Left and Right): Some delimited files contain enclosures that denote text strings within a field. If the file contains enclosures, enter an enclosure character in the text box or select one from the list. The list displays commonenclosures. However, you may enter any character. The default for both the left and right enclosure is the double quotation mark ("). You can specify multiple characters and hexadecimal characters as field enclosures."
    But it will not work. The OWB use the first character from the left enclosure definition as left enclosure and the second one as right enclosure !?!
    Did anyone know this behavior? Is there a solution for this problem?
    Thanks and regards
    Norbert

    HI Raghu,
               Use the function module 'GUI_UPLOAD'.
               In that you have to specify the field_separator value = 'X' in export section.
    Regards,
    S.C.K

  • Word files with no extensions  .doc

    Hi
    if a start up staroffice 8.0 on linux with a word file, with no .doc extension it's not working.
    soffice file (works on solaris, does not work on linux)
    soffice file.doc ( works on both platforms)
    It looks like the soffice solaris version loads the word filter but the linux
    version loads a wordperfect filter.
    Is there a place to configure the behavior.
    Thanks Manuel

    Is there no one who can confirm this bug?

  • How to create a pdf file with CS5

    Hello, I'm new to PhotoShop CS5 and haven't figured out yet (despite two hours of trying) how to create a pdf file with pictures and texts.  Can someone please help me with this ?  The "help" button in CS5 doesn't seem to cover this question.  Nor do the FAQs.
    Thank you very much.

    Save As... Photoshop PDF.

  • Batch create from Word files

    Hi everyone,
    I'm trying to use the batch create multiple files command in Acrobat 10.1.3 to create a pdf from multiple word files but when I try to add the files, all Word files are greyed out.
    Is it possible to batch create from Word files or is that why they're greyed out?
    Appreciate any help.

    In the current version of Acrobat on the Macintosh, Word files are not supported. They are supported in the Windows version. It's been this way for a very long time.

  • I created a word document with hyperlinks. When my default browser is Chrome the hyper links work. When the default browser is Safari, the hyperlinks bring to pages that just lines and lines of symbols. I need these links to work in both browsers.

    I created a word document with hyperlinks. When my default browser is Chrome the hyper links work. When the default browser is Safari, the hyperlinks bring to pages that just lines and lines of symbols. I need these links to work in both browsers. Any ideas?

    version 10.6.8

Maybe you are looking for

  • Removing Photos Not Used in Albums from Library

    Is there a way to filter out the pictures (within the Library) not being used in any of the albums and mark them for deletion? Is this something that either iPhote 6 or that another application might address?

  • Syncing Ipad 3 after deleting songs

    Hey, I want to erase a bunch of songs off my Ipad.  When I go and sync the ipad again with my main computers Itunes will it delete them on the main computer as well?

  • My Iphone 4S will not sync with my macbook air

    Thought i would ask for help here. Seems the sync server is always down. What am i doing wrong? Thanks

  • Returned Failure Exit Code 1603

    I am having an issue with one server in particular trying to install the CM client. The server is running Server 2008 R2 and is used as our primary file server. ccmsetup.log repeats the following line... ![LOG[File 'C:\Windows\ccmsetup\vcredist_x86.e

  • I need help with a problem submitting my podcasts to iTunes

    When I submit my podcast from iWeb to iTunes, iTunes asks for the URL link which is already filled in. When I press the "Continue" button I get the same response over and over again -- "We experienced a timeout connecting to this feed at this time. R