We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Failing to accept changes: Invalid document model

The attached document opens fine in Word, and I am able to freely accept/reject the changes. However, when I attempt to do the following on it using Aspose 21.10:

Document document = new Document(new FileInputStream(new File(inputPath)));
final List<Revision> formatRevisions = new ArrayList<Revision>();
for (Revision revision : document.getRevisions()) {
  if (revision.getRevisionType() == RevisionType.FORMAT_CHANGE) {
    formatRevisions.add(revision);
  }
}
for (Revision revision : formatRevisions) {
  revision.accept();
}

I get the following exception:

Caused by: java.lang.IllegalStateException: Invalid document model. Operation can not be completed.
        at com.aspose.words.zzVRM.zzZdX(Unknown Source)
        at com.aspose.words.zzVRM.zzWPL(Unknown Source)
        at com.aspose.words.zzVRM.zzFe(Unknown Source)
        at com.aspose.words.zzVRM.zzVTQ(Unknown Source)
        at com.aspose.words.zzYGb.zzWPL(Unknown Source)
        at com.aspose.words.zzYGb.zzWgK(Unknown Source)
        at com.aspose.words.zzYGb.zznj(Unknown Source)
        at com.aspose.words.zzYGb.zzWPL(Unknown Source)
        at com.aspose.words.Revision.zzWPL(Unknown Source)
        at com.aspose.words.Revision.accept(Unknown Source)
// snip

revisions.docx (11.5 KB)

@icsk

We have logged this problem in our issue tracking system as WORDSNET-22956. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-22956) have been fixed in this Aspose.Words for Java 22.1 update.