How to use OLE Components in Java Application?

Hi,
I try to make program that is able to include OLE components( Excel sheet, MS Word document, and so on ), and that can control these components.
I want to know that Java Application or Applet can control and show OLE components like JavaBeans components. If that, How to ?

Try this to generate a Word file.....
import com.jacob.activeX.*;
import com.jacob.com.*;
public class ExportDOC {
public ExportDOC () {
//Application type
ActiveXComponent doc = new ActiveXComponent("Word.Application");
//Application visible
doc.setProperty("Visible", new Variant(true));
Object documents = doc.getProperty("Documents").toDispatch();
//Open a file already exits
//Object document = Dispatch.call(documents, "Open", "c:/nameFile.doc").toDispatch();
//Open a new file empty
Object document = Dispatch.call(documents, "Add", "").toDispatch();
Object selection = Dispatch.get(doc,"Selection").toDispatch();
//Text Format
Object font = Dispatch.get(selection, "Font").toDispatch();
Object alignment = Dispatch.get(selection, "ParagraphFormat").toDispatch();
Object image = Dispatch.get(selection, "InLineShapes").toDispatch();
//I put the selection at the end of the file for if I want to add text
//Dispatch.call(selection, "EndKey", "6");
//Text format (bold & italic)
Dispatch.put(font, "Bold", "1");
Dispatch.put(font, "Italic", "1");
//To jump line
Dispatch.call(selection, "TypeParagraph");
//Align center (0= left, 1=center, 2=right, 3=justify)
Dispatch.put(alignment, "Alignment", "1");
//Insert image
Dispatch.call(image, "AddPicture", "c:/graf.jpg");
Dispatch.call(selection, "TypeParagraph");
Dispatch.put(alignment, "Alignment", "3");
//Insert Text
Dispatch.call(selection, "TypeText", "Text ....... ");
//Original values
Dispatch.call(selection, "TypeParagraph");
Dispatch.put(alignment, "Alignment", "0");
Dispatch.put(font, "Bold", "0");
Dispatch.put(font, "Italic", "0");
//To jump page
//Dispatch.call(select, "InsertBreak");
//Save the document
//Dispatch.call(document, "SaveAs", "c:/test.doc");
//Quit the application
//dc.invoke("Quit", new Variant[] {});
public static void main(String[] args) {
ExportDOC e = new ExportDOC();
but you must download 'jacob.jar' in....
http://users.rcn.com/danadler/jacob/
is a FREEWARE!!!
regards!!

Similar Messages

  • How to use " toFront() " method in java application and in which package or

    How to use " toFront() " method in java application and in which package or class having this toFront() method.if anybody know pl. send example.

    The API documentation has a link at the top of every page that says "Index". If you follow that and look for toFront(), you will find it exists in java.awt.Window and javax.swing.JInternalFrame.
    To use it in a Java application, create an object x of either of those two classes and write "x.toFront();".

  • How to use a proxy with java applications?

    I have a nokia 6300 type s40v3
    hello,
    I would like to know if it is possible to use a proxy of any and how ? kind with java applications.
    thank you

    Well, it works well when, into my applet, i do somethig like this:
    URL url = new URL(host);
    URLConnection connexion = url.openConnection();My applet uses proxy setting from IE6 but only if i use Java 1.4.2_08.
    With IE6 and Java 1.5.04, it doesn't work (my applet doesn't use proxy settings)
    With Firefox and Java 1.5.04, it's ok
    Have you already seen a problem like this with Java 1.5.04 ?

  • Using Flex components in Java application

    Hello,
    I was learning Flex previously, and I thought I remembered reading somewhere that I can use Flex UI components in a Java application. For instance, I could use Flex for the UI, and Java for the backend. I can't find though the documentation for this. I read this last summer. I don't mean using Flex as a UI in a browser and Java on the server, but a Java application that runs on the client with a Flex UI. I thought what I needed was the flex compiler api, but I looked at the flex compiler api documentation and it isn't what I want.
    Does anyone know what this "part" of Flex is that I am talking about, but can't remember?
    Thanks,
    Vance

    No, thanks, but that wasn't what I was thinking of.
    What I remember looking at was some library that allowed wrapping Flex UI componnts in Java Swing components. Then the Swing components could be used in the Java app. One main objective of my wrapping Flex in Java is to use flash.media.Video class to play flash video.

  • HOW TO use OCX controls with Java application

    hi
    Is it possible to use microsoft Ocx controls in java applications.

    Anything is possible. You might want to ask if it's a good idea, but look at some of the people who have asked before. It looks like there are products out there to help.
    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2Btitle%3Aocx&col=javaforums&x=19&y=13

  • Can I use Streaming Video in Java Application?

    Will i be able to use Streaming Video in Java Application, if yes can anyhow out there pls teach me how to do it... thanks...

    read up on the Java Medai Framework http://java.sun.com/products/java-media/jmf/index.html

  • How to use C-Structure in java applets

    hi alls,
    I want to use a struct model (struct in C++) in java applets. i know class is used in java applications. but, how can i convert in java applets?
    class renk
    int r;
    int gr;
    int b;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.Event;
    import java.applet.Applet;
    public class benek extends Applet
    final int n=10;
    int x[] = new int[n];
    int y[] = new int[n];
    int count = 0;
    renk clr[] = new renk[n];
    public void init()
    setBackground(Color.black);
    public boolean mouseDown(Event yordam, int xyer, int yyer)
    if (count<n)
    System.out.println("...");
    ekle(xyer,yyer);
    else System.out.println("Kapasite Doldu...");
    return true;
    void ekle(int xyer, int yyer)
    int r1 = (int)Math.floor(Math.random()*256);
    int gr1 = (int)Math.floor(Math.random()*256);
    int b1 = (int)Math.floor(Math.random()*256);
    clr[count].r = r1;
    clr[count].gr = gr1;
    clr[count].b = b1;
    x[count]=xyer;
    y[count]=yyer;
    count++;
    repaint();
    public void paint(Graphics g)
    it gives error message... how can � use struct model in java applets???
    if you help me i will be greatfull....

    � use import but it doesn't work.
    i add: import renk; or import class renk;
    how will � add import I assumed based on your initial post that the renk and benek classes were in the same file. Apparently you're saying they are not. So for another thing, make your renk class "public class renk", and add the "public" keyword to the 3 members of that class. Then if your code still doesn't see the "renk" class, it would just be that you don't have the directory that contains the compiled "renk.class" in your classpath.

  • How do i show javascript into  java application?

    hi
    ( please help me!!!!!!!!!!!!!!!!!)
    how do i run javascript into java application ?( looks like microsoft frontpage )
    thank you ?

    There is a JavaScript interpreter called Rhino implemented in Java, maybe you can use it: http://www.mozilla.org/rhino/

  • How to add images into a java application (not applet)

    Hello,
    I am new in java programming. I would like to know how to add images into a java application (not an applet). If i could get an standard example about how to add a image to a java application, I would apreciated it. Any help will be greatly apreciated.
    Thank you,
    Oscar

    Your' better off looking in the java 2d forum.
    package images;
    import java.awt.*;
    import java.awt.image.*;
    import java.io.FileInputStream;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    /** * LogoImage is a class that is used to load images into the program */
    public class LogoImage extends JPanel {
         private BufferedImage image;
         private int factor = 1; /** Creates a new instance of ImagePanel */
         public LogoImage() {
              this(new Dimension(600, 50));
         public LogoImage(Dimension sz) {
              //setBackground(Color.green);      
              setPreferredSize(sz);
         public void setImage(BufferedImage im) {
              image = im;
              if (im != null) {
                   setPreferredSize(
                        new Dimension(image.getWidth(), image.getHeight()));
              } else {
                   setPreferredSize(new Dimension(200, 200));
         public void setImageSizeFactor(int factor) {
              this.factor = factor;
         public void paintComponent(Graphics g) {
              super.paintComponent(g);
              //paint background 
              Graphics2D g2D = (Graphics2D) g;
              //Draw image at its natural size first. 
              if (image != null) {
                   g2D.drawImage(image, null, 0, 0);
         public static LogoImage createImage(String filename) { /* Stream the logo gif file into an image object */
              LogoImage logoImage = new LogoImage();
              BufferedImage image;
              try {
                   FileInputStream fileInput =
                        new FileInputStream("images/" + filename);
                   image = ImageIO.read(fileInput);
                   logoImage =
                        new LogoImage(
                             new Dimension(image.getWidth(), image.getHeight()));
                   fileInput.close();
                   logoImage.setImage(image);
              } catch (Exception e) {
                   System.err.println(e);
              return logoImage;
         public static void main(String[] args) {
              JFrame jf = new JFrame("testImage");
              Container cp = jf.getContentPane();
              cp.add(LogoImage.createImage("logo.gif"), BorderLayout.CENTER);
              jf.setVisible(true);
              jf.pack();
    }Now you can use this class anywhere in your pgram to add a JPanel

  • How to use openjpa  + kodo in Java SE?

    Hi.
    We are developing J2EE application on Weblogic Server 9. For a part of application we should create unit tests that will be run in Java SE. How to use openjpa + kodo in Java SE?

    Hi,
    Try the EclipseLink JPA JEE5/JEE6 provider - it has been shipping as part of WebLogic Server since 10.3.1.0.
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    The following page has several SE, application-managed and container-managed EE example tutorials with source.
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial
    http://wiki.eclipse.org/EclipseLink/Examples/JPA
    The following forum will help you with any JPA specific issues.
    Forum: TopLink/JPA
    TopLink/JPA
    thank you
    /michael
    http://www.eclipselink.org

  • How to run ear file in java application server

    i want how to run .ear file in java application server
    1. i m created ear file
    2. i m created jar file (bean,home,remote)
    3.i m created war file(in the form of jsp)
    but till now i couldnt run ear file
    how to run
    please hel me

    You must create :
    1.Jar file
    2.War file
    And then put them into an ear file
    Exemple : myapp.ear contains
    myappEJB.jar
    myappWEB.war
    META-INF/application.xml
    and application.xml looks like this :
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
                            http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
        <display-name>myapp</display-name>
        <description>Demo application</description>
        <module>
            <ejb>myappEJB.jar</ejb>
        </module>
        <module>
          <web>
             <web-uri>myappWAR.war</web-uri>
             <context-root>/myapp</context-root>
          </web>
        </module>
    </application>Good luck

  • How to use sql query in java ?

    i don't know how to use sql query in java code.
    who can give me some advice?
    thanks

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • How many web.xml in a java application

    Hi,
    can anyone give tell the answer for this question "How many web.xml in a java application?"

    1Why ?Because the Web container refers to only one web.xml for one web application.
    I havent heard of an application having more than 1 web.xml
    How?It reads all the definitions of servlet mappings, filters, welcome-file etc from this file itself.
    Where?From the following folder ...
    /WEB-INF
    By the way ..... the way you questioned me was amuzing ... Why? How ?Where ? Its funny :D
    I actually wanted to reply as below ..
    Why ?Why not
    How?
    Wait lemme think ....ummm... What do you mean how??
    Where ?
    Inside the web ;-)
    -Rohit

  • How do i  open browser in java application

    hi....
    please help me!!!!!!!!!!!!!!!!!!!!!!!!!!
    how do i open browser in java application ? ( for show javascript in java application)
    thank you.......

    You can run any program from java by doing
    Runtime.getRuntime().exec("mybrowser myjavascriptfile.js");
    The real question is why would you want to.
    I would suggest you rethink whether running Javascript from Java is a good idea.

  • What is Digital Signature, How to use it in web based applications?

    I am new to digital signatures. Any body can help me how to create a digital signature and how to use it in web based applications. Do we need certificates to use digital signatures?

    <link_farm_and_everything_else_removed_by_moderator>
    Edited by: Julius Bussche on Sep 3, 2008 8:59 AM

Maybe you are looking for

  • Issue in Adding  Incoming Payment

    Hi, when i am trying to raise the incoming payment i get the error - >"Invoice is already closed or blocked" plz Reply

  • Load Balancing with OSPF and maximum-paths command

    Hello, Just a quick query really, we have a disribution layer 3 switch, in its routing table it has 3 default routes all with the same metric from the core router, this is because the core router is setup with the comamnd "default-information origina

  • Keynote Address by Steve Jobs

    Hi, I'm trying to watch the Keynote Address and the iPhone Introduction via video-on-demand, but unfortunately the video won't load. QuickTime will start up and everything, but it won't stop loading. I can keep it running for an hour, all I get is th

  • CS5.5 Rectangle tool blue and brown outlines?

    I don't understand the blue and brown colored lines that outline the rectangle/ellipsed boxes I create.  Clicking on a blue outlined box sometimes causes it to turn brown, and then do odd things, like when I move the box, it sometimes completely disa

  • Change "Message from administrator" in PXE

    Hello, I am wondering if you can change the default message from administrator from the looking for policy to something custom.  I tried looking in the PXE settings on the DP role and also tried to run a wdsutil set server message from cmd prompt on