Package com.jacob.activeX

Examples of com.jacob.activeX.ActiveXComponent


   * @param f
   * @throws VisioException
   */
  public void open(File f) throws VisioException {
    try {
      ActiveXComponent documents = new ActiveXComponent(getProperty(
          "Documents").toDispatch());
      Variant[] args = new Variant[1];
      args[0] = new Variant(f.getPath());
      documents.invoke("Open", args);
    } catch (Exception e) {
      e.printStackTrace();
      throw new VisioException(e);
    }
  }
View Full Code Here


   *
   * @throws VisioException
   */
  public void save() throws VisioException {
    try {
      ActiveXComponent document = new ActiveXComponent(getProperty(
          "ActiveDocument").toDispatch());
      document.invoke("Save");
    } catch (Exception e) {
      e.printStackTrace();
      throw new VisioException(e);
    }
  }
View Full Code Here

*/
public class ScriptTest extends BaseTestCase {

  public void testStupidSpeedTest() {
    String lang = "VBScript";
    ActiveXComponent sC = new ActiveXComponent("ScriptControl");
    Dispatch sControl = sC.getObject();
    Dispatch.put(sControl, "Language", lang);
    for (int i = 0; i < 10000; i++) {
      Dispatch.call(sControl, "Eval", "1+1");
    }
  }
View Full Code Here

    // shutdown should be done through other means
    // whoever wrote this example should explain what this was intended to
    // do
    // System.runFinalizersOnExit(true);

    ActiveXComponent mf = new ActiveXComponent("MultiFace.Face");
    try {
      // I am now dealing with the default interface (IFace1)
      Dispatch.put(mf, "Face1Name", new Variant("Hello Face1"));
      System.out.println(Dispatch.get(mf, "Face1Name"));

      // get to IFace2 through the IID
      Dispatch f2 = mf
          .QueryInterface("{9BF24410-B2E0-11D4-A695-00104BFF3241}");
      // I am now dealing with IFace2
      Dispatch.put(f2, "Face2Nam", new Variant("Hello Face2"));
      System.out.println(Dispatch.get(f2, "Face2Nam"));

      // get to IFace3 through the IID
      Dispatch f3 = mf
          .QueryInterface("{9BF24411-B2E0-11D4-A695-00104BFF3241}");
      // I am now dealing with IFace3
      Dispatch.put(f3, "Face3Name", new Variant("Hello Face3"));
      System.out.println(Dispatch.get(f3, "Face3Name"));
View Full Code Here

   */
  public void quit() {
    System.out.println("Received quit()");
    // there can't be any open documents for this to work
    // you'll get a visio error if you don't close them
    ActiveXComponent document = new ActiveXComponent(getProperty(
        "ActiveDocument").toDispatch());
    document.invoke("Close");
    invoke("Quit");
  }
View Full Code Here

    Dispatch sControl = null;

    try {
      String scriptCommand = getSampleVPScriptForEval();
      String lang = "VBScript";
      ActiveXComponent sC = new ActiveXComponent("ScriptControl");
      sControl = sC.getObject();
      Dispatch.put(sControl, "Language", lang);
      ScriptTestErrEvents te = new ScriptTestErrEvents();
      de = new DispatchEvents(sControl, te);
      if (de == null) {
        System.out
View Full Code Here

   * @param f
   * @throws VisioException
   */
  public void export(File f) throws VisioException {
    try {
      ActiveXComponent document = new ActiveXComponent(getProperty(
          "ActivePage").toDispatch());
      Variant[] args = new Variant[1];
      args[0] = new Variant(f.getPath());
      document.invoke("Export", args);
    } catch (Exception e) {
      throw new VisioException(e);
    }
  }
View Full Code Here

  /**
   * verify safe arrays work with standard applications, Excel in this case
   */
  public void testSafeArrayViaExcel() {

    ActiveXComponent xl = new ActiveXComponent("Excel.Application");
    try {
      Dispatch cell;
      SafeArray sAProdText;
      Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
      System.out.println("have workbooks");
      Dispatch workbook = Dispatch.call(
          workbooks,
          "Open",
          getWindowsFilePathToPackageResource(
              "SafeArrayViaExcel.xls", this.getClass()))
          .toDispatch();
      System.out.println("Opened File - SafeArrayViaExcel.xls\n");
      Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch();
      cell = Dispatch.invoke(sheet, "Range", Dispatch.Get,
          new Object[] { "A1:D1000" }, new int[1]).toDispatch();
      System.out.println("have cell:" + cell);
      sAProdText = Dispatch.get(cell, "Value").toSafeArray();
      System.out.println("sa: dim=" + sAProdText.getNumDim());
      System.out.println("sa: start row=" + sAProdText.getLBound(1));
      System.out.println("sa: start col=" + sAProdText.getLBound(2));
      System.out.println("sa: end row=" + sAProdText.getUBound(1));
      System.out.println("sa: end col=" + sAProdText.getUBound(2));
      int i;
      int lineNumber = 1;
      int n = 0;
      for (lineNumber = 1; lineNumber < 1000; lineNumber++) {
        for (i = 1; i < 4; i++) {
          System.out.println((n++) + " " + lineNumber + " " + i + " "
              + sAProdText.getString(lineNumber, i));
          /*
           * if (sAProdText.getString(lineNumber,i).compareTo("aaaa") !=
           * 0 ) { System.out.println("Invalid String in line " +
           * lineNumber + " Cell " + i + " Value = " +
           * sAProdText.getString(lineNumber,i)); stringFound = false; } }
           * if (stringFound) { System.out.println("Valid Strings in
           * line " + lineNumber); lineNumber++; }
           */
        }
      }

      Dispatch.call(workbook, "Close");
      System.out.println("Closed File\n");
    } catch (Exception e) {
      e.printStackTrace();
      fail("Caught Exception " + e);
    } finally {
      xl.invoke("Quit", new Variant[] {});
    }
  }
View Full Code Here

    public void run() {
      try {
        ComThread.InitMTA();
        System.out.println("OnInit");
        String lang = "VBScript";
        sC = new ActiveXComponent("ScriptControl");
        sControl = sC.getObject();
        Dispatch.put(sControl, "Language", lang);
        ScriptTestErrEvents te = new ScriptTestErrEvents();
        de = new DispatchEvents(sControl, te);
        System.out.println("sControl=" + sControl);
View Full Code Here

   *            the event
   */
  public void actionPerformed(ActionEvent ev) {
    if (sC == null) {
      String lang = "VBScript";
      sC = new ActiveXComponent("ScriptControl");
      Dispatch.put(sC, "Language", lang);
    }
    Variant v = Dispatch.call(sC, "Eval", in.getText());
    out.setText(v.toString());
  }
View Full Code Here

TOP

Related Classes of com.jacob.activeX.ActiveXComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.