Macro doesn't update all Stories of type wdTextFrameStory

We found a specific problem in Word documents which are generated by Aspose.Words Java version 10.0 and 10.1, which did not occur in version 2.0.4 (also Java). In each generated document, we run a macro that (among other things) updates all fields in all parts of the document, so that the document reflects correct values. The VBA code is shown below:

Sub UpdateDocProps()
    Dim oStory As Object For Each oStory In ActiveDocument.StoryRanges
        oStory.Fields.Update 'update fields in all stories
    Next oStory
End Sub

We have several stories in our document that have StoryType = wdTextFrameStory. The problem is that in documents generated with the latest versions of Aspose.Words, the loop will visit only one story of type wdTextFrameStory, thus ignoring the rest of them. This loop worked fine in the earlier version.

Hi Ischa,
Thanks for your request. Could you please attach your document here for testing? I will check the issue on my side and provide you more information.
Also, as you may know starting from 10.0.0 version Aspose.Words has its own fields updating engine.
This engine can update almost all fields. So you can avoid using macros at all. Please follow the link to learn how to update fields using Aspose.Words.
Best regards,

Hi Alexey,
It seems that our conclusion was a bit premature. Aspose doesn’t tamper with the macros. But it is doing something with the textframes. I included two documents. in.doc contains textframes. out.doc is the document generated/merged by Aspose. The textframes are now textareas. Apparently the textarea’s are not ‘seen’ by the macro so the field are not updated. I hope you can look into the problem.
Thank you in advance,
P.S. the macros are used to do some postprocessing.

Thank you for additional information. Probably the problem occurs because you are calling UpdatePageLayout, update fields or render the document. All this operation calls UpdatePageLayout method. At the moment to layout text frames Aspose.Words converts them to TextBox shapes. That is why in your output document all frames are converted to textboxes.
We plan to fix this problem in one of future versions. We will notify you once the problem is resolved.
Best regards,

Thank you for your quick response.
In fact we execute a mailmerge (document.getMailMerge().execute()). So I think the UpdatePageLayout will also be called after executing the mailmerge. Is there a way to prevent Aspose from executing UpdatePageLayout?

Thanks for your request. When you execute mail merge, Aspose.Words internally calls UpdateFieds method. This method in turn calls UpdatePageLayout method to layout the document. This method is called to update field that rely on page numbers. So there is no way to prevent executing UpdatePageLayout
Best regards,

Hello Alexey,

Do you have an estimate for the next release? And do you already know if
the bug mentioned in this topic will be solved in the next release?



Thanks for your inquiry. Aspose.Words releases are published every 4-5 weeks. But currently, I cannot provide you an exact date when this feature will be available. Hopefully it will be available in month or two. You will be notified.
Best regards,

The issues you have found earlier (filed as WORDSNET-2219) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.