Examples of Dispatch


Examples of com.jacob.com.Dispatch

    ActiveXComponent xl = new ActiveXComponent("Excel.Application");
    try {
      System.out.println("version=" + xl.getProperty("Version"));
      System.out.println("version=" + Dispatch.get(xl, "Version"));
      Dispatch.put(xl, "Visible", new Variant(true));
      Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
      Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch();
      Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch();
      Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
          new Object[] { "A1" }, new int[1]).toDispatch();
      Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get,
          new Object[] { "A2" }, new int[1]).toDispatch();
      Dispatch.put(a1, "Value", "123.456");
      Dispatch.put(a2, "Formula", "=A1*2");
      System.out.println("a1 from excel:" + Dispatch.get(a1, "Value"));
      System.out.println("a2 from excel:" + Dispatch.get(a2, "Value"));
View Full Code Here

Examples of com.jacob.com.Dispatch

   * written
   */
  public void runTest() {
    // deprecated
    // System.runFinalizersOnExit(true);
    Dispatch test = new ActiveXComponent("MathTest.Math");
    TestEvents te = new TestEvents();
    DispatchEvents de = new DispatchEvents(test, te);
    if (de == null) {
      System.out
          .println("null returned when trying to create DispatchEvents");
View Full Code Here

Examples of com.jacob.com.Dispatch

  private static void recurseFolders(int iIndent, Dispatch o) {

    if (o == null) {
      return;
    }
    Dispatch oFolders = Dispatch.get(o, "Folders").toDispatch();
    // System.out.println("oFolders=" + oFolders);
    if (oFolders == null) {
      return;
    }

    Dispatch oFolder = Dispatch.get(oFolders, "GetFirst").toDispatch();
    do {
      Object oFolderName = Dispatch.get(oFolder, "Name");
      if (null == oFolderName) {
        break;
      }
View Full Code Here

Examples of com.jacob.com.Dispatch

    ActiveXComponent axOutlook = new ActiveXComponent("Outlook.Application");
    try {
      System.out.println("version=" + axOutlook.getProperty("Version"));

      Dispatch oOutlook = axOutlook.getObject();
      System.out.println("version=" + Dispatch.get(oOutlook, "Version"));

      Dispatch oNameSpace = axOutlook.getProperty("Session").toDispatch();
      System.out.println("oNameSpace=" + oNameSpace);

      recurseFolders(0, oNameSpace);

    } finally {
View Full Code Here

Examples of com.jacob.com.Dispatch

      // 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

Examples of com.jacob.com.Dispatch

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

Examples of com.jacob.com.Dispatch

  }

  public void testCreatingDispatchEvents() {
    ComThread.InitSTA(true);
    DispatchEvents de = null;
    Dispatch sControl = null;

    try {
      String scriptCommand = getSampleVPScriptForEval();
      String lang = "VBScript";
      ActiveXComponent sC = new ActiveXComponent("ScriptControl");
View Full Code Here

Examples of com.jacob.com.Dispatch

   */
  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());
View Full Code Here

Examples of com.jacob.com.Dispatch

    // this only works for access files pre-access-2000
    // this line doesn't work on my xp box in Eclipse
    // Dispatch db = open(ax, ".\\sample2.mdb");
    // this works when running in eclipse because the test cases run pwd
    // project root
    Dispatch db = open(ax, "samples/com/jacob/samples/access/sample2.mdb");
    String sql = "select * from MainTable";
    // make a temporary querydef
    Dispatch qd = Dispatch.call(db, "CreateQueryDef", "").toDispatch();
    // set the SQL string on it
    Dispatch.put(qd, "SQL", sql);
    Variant result = getByQueryDef(qd);
    // the 2-d safearray is transposed from what you might expect
    System.out.println("resulting array is " + result.toSafeArray());
View Full Code Here

Examples of com.jacob.com.Dispatch

   */
  public static Dispatch open(ActiveXComponent ax, String fileName) {
    Variant f = new Variant(false);
    // open the file in read-only mode
    Variant[] args = new Variant[] { new Variant(fileName), f, f };
    Dispatch openDB = ax.invoke("OpenDatabase", args).toDispatch();
    return openDB;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.