insert image into excel

prioux
2012-06-21
2013-05-20
  • prioux

    prioux - 2012-06-21

    Hello.
    i word with jacob 1.17 under Eclipse.
    I open a file Excel and i try to insert images in it.
    ActiveXComponent xl = new ActiveXComponent("Excel.Application");
        Dispatch xlo = (Dispatch) xl.getObject();
        try { 
        System.out.println("version="+xl.getProperty("Version")); 
        System.out.println("version="+Dispatch.get(xlo, "Version")); 
        xl.setProperty("Visible", new Variant(true)); 
    //             
        Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();
    //
        File file=new File("\\…\\Trombi.xls");
        Dispatch workBook = Dispatch.call(workbooks, "Open", file.getAbsolutePath()).toDispatch();
        Dispatch sheet = Dispatch.get(workBook,"ActiveSheet").toDispatch();

        Dispatch pictures = Dispatch.get(sheet, "Pictures").toDispatch();
        Dispatch newPicture = Dispatch.call(pictures, "Add", "…\monimage.jpg").toDispatch();

    But I have an error:
    com.jacob.com.ComFailException: A COM exception has been encountered:
    At Invoke of: Add
    Description: Parameter not optional.
    ….
    What's happen?

     
  • motron

    motron - 2012-06-28

    did u ever try something like this  ActiveSheet.Pictures.Insert("C:\Users\mo..")
    in Excel's VBA  ActiveSheet.Pictures.Add with 1 Parameter leads to this "Parameter not optional" runtimeError 449.
    1. try in Excel
    2. with a vbs-script
    3. tranfer to jacob

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks