Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update

Last post 11-08-2010, 5:36 AM by alexey.noskov. 7 replies.
Sort Posts: Previous Next
  •  11-02-2010, 10:43 PM 267053

    Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update Java

    Hi ,

    For Word 2007,  insert images from files into docm and docx documents through API DocumentBuilder.insertImage, and then running below macro. The inserted images can not display well, instead display cross marks:

    ActiveDocument.Fields.Update


    After investigation, found that the images were insert into docm and docs files as below fields, not real images:

    {INCLUDEPICTURE  \d "ooxWord://word/media/image1.png" \* MERGEFORMATINET}
    {INCLUDEPICTURE  \d "ooxWord://word/media/image1.png" \* MERGEFORMATINET}

    Running the macro may delete the "media" folder of docm and docx. So cross mark was displayed there instead.

    But for doc format, the images were inserted into as real images, so there no problems with doc files.

    For you convenience, I pasted the code:

    Main.java

    public static void main(String[] args) throws Exception {
            String out1 = "files\\out1.doc";
            String out2 = "files\\out2.docm";
            String out3 = "files\\out3.docm";
            String styleDoc = "files\\test.dot";
            Document doc = new Document(styleDoc);
            DocumentBuilder docBuilder = new DocumentBuilder(doc);       
            //insert images   
            Shape shape1 = docBuilder.insertImage("files\\OLE0.png");
            shape1.setWrapType(WrapType.INLINE);       
            docBuilder.writeln();       
            Shape shape2 = docBuilder.insertImage("files\\OLE1.png");
            shape2.setWrapType(WrapType.INLINE);       
            //save documents       
            doc.save(out1);       
            doc.save(out2);
            doc.save(out3);
                   
            //run macro for out2.docm
            String command = "cscript files\\runmacro.vbs " + new File(out2).getAbsolutePath() + " peUpdateFields";   
            System.out.println(command);
            Process proc = Runtime.getRuntime().exec(command);
            proc.waitFor();
        }

    runmacro.vbs:

    ' ignore errors
    On Error Resume Next

    ' start only if 2 arguments are provided
    if WScript.Arguments.Count <> 2 then
        wscript.quit
    end if

    Set word = CreateObject("Word.Application")
    word.Visible = TRUE

    Set doc = word.Documents.Open( Wscript.Arguments(0))
    if doc <> nul then
        word.Run( Wscript.Arguments(1))
        word.ActiveDocument.Save
    end if

    word.quit   

    The test.dot file just contian an macro peUpdateFields:

    ' Updates all the fields in the document
    Public Sub peUpdateFields()
        ActiveDocument.Fields.Update
    End Sub



    Is it a defect of Aspose.Words library? Are there any ways to solve this issue?

    Thanks.

     
  •  11-03-2010, 8:34 AM 267136 in reply to 267053

    Re: Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update

    Hi

     

    Thanks for your inquiry. I cannot reproduce the problem on my side. As I can see Aspose.Words inserts images as embedded.

    Could you please attach your output document here for testing? I will check the issue and provide you more information.

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  11-03-2010, 9:33 PM 267291 in reply to 267136

    Re: Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update

    Attachment: Present (inaccessible)
    I attached all source code and out put files.

    You just open out2.docm and will see the issue.

    BTW, my Aspose.Words version is 2.5.0.

    Thanks.
     
  •  11-04-2010, 3:48 AM 267339 in reply to 267291

    Re: Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update

    Hi

     

    Thank you for additional information. I used the latest version of Aspose.Words for testing and all images are includes as embedded. So, please try using the latest version. You can download it from here:

    http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/category1378.aspx

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  11-04-2010, 10:22 PM 267492 in reply to 267339

    Re: Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update

    Can fix it in version 2.5.0?

    Thanks
     
  •  11-05-2010, 7:13 AM 267562 in reply to 267492

    Re: Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update

    Hi

     

    Thanks for your inquiry. As an option, you can use DOC format instead of DOCX. In this case, your images will be surely included as embedded.

    Have you tried with newer version of Aspose.Words? Did this resolve your issue?

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  11-07-2010, 9:13 PM 267796 in reply to 267562

    Re: Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update

    I tried the newer version, it can resolve my issue.

    But we must support docm and docx format for our customers. It is very helpful if the defect can be fixed in the older version.

    Thanks.
     
  •  11-08-2010, 5:36 AM 267861 in reply to 267796

    Re: Images inserted into docm and docx can not dislay after running macro ActiveDocument.Fields.Update

    Hi Vincent,

     

    Thanks for your request. I am afraid, I cannot suggest you any way to resolve this with old version of Aspose.Words. You should consider updating to the newer version of Aspose.Words.

     

    Best regards,


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
View as RSS news feed in XML