Word 2013 document after update link cannot be opened in O365

Hi team,

after, via Aspose.Words, I updated link in Word 2013 document, later changed file cannot be opened anymore in O365. O365 reports that file is corrupted. Can you please check attachment?
Changed document is Updated.docx.

Thanks,
Oliver

O365.zip (95.3 KB)
This time attachment.

@dr.doc

Could you please ZIP and attach the code example that you are using to generate Updated.docx? We will investigate the issue and provide you more information on it.

Hi Tahir,

this was part of large project so I tried to prepare something and when I run attached project I see that file of similar size is created (difference 1 byte) so can you please try attached project.

WordM365.zip (216.4 KB)

Thanks,
Oliver

@dr.doc

We have tested the scenario using the latest version of Aspose.Words for .NET 21.11. The output document is open by MS Word at our end. So, please use Aspose.Words for .NET 21.11.

We have attached the output document with this post for your kind reference.
Result 21.11.docx (49.4 KB)

Thanks, I’ll update version and try again.
Btw.Did you try to open this file with O365 Word application?

Also, why when I put this

        DocSaveOptions options = new DocSaveOptions();
        options.SaveFormat = SaveFormat.Docx;

in front of

        doc.Save("Result.docx", options);

I am getting:

Unhandled Exception: System.ArgumentException: An invalid SaveFormat for this options type was chosen.
at Aspose.Words.Saving.DocSaveOptions.:slight_smile:(SaveFormat :slight_smile:)
at Aspose.Words.Saving.DocSaveOptions.set_SaveFormat(SaveFormat value)
at Aspose_Word.WordTest.ReplaceHyperlinksNew() in C:_Projects\Bugs\Aspose\0\Aspose.Bugs\Word.cs:line 225
at ReplaceTextInSinglePageOfPDF.Program.Main(String[] args) in C:_Projects\Bugs\Aspose\0\Aspose.Bugs\Program.cs:line 128

Is this file really .docx? Btw. is there any why that when I ope file I can see what is document format?

Thanks,
Oliver

I found problem - document is not of .docx type like extension tells but old .doc format.

Now, problem here is that I would expect that when we open document and make processing and then later try to save document with SaveFormat = SaveFormat.Docx document is saved (converted) as a .docx file.

Is there any way how to enforce that save of opened document is no matter on document format is exactly like I specify with

OoxmlSaveOptions options = new OoxmlSaveOptions();
        options.SaveFormat = SaveFormat.Docx;

@dr.doc

It is nice to hear from you that your problem has been solved.

Unfortunately, your requirement is not clear enough. Could you please share some more detail about your requirement?

If you want to save the document with the same file format that you import into Aspose.Words’ DOM, you can use Document.OriginalLoadFormat property to get the original file format of document. If this property returns DOCX, you can use OoxmlSaveOptions and if it returns DOC, you can use DocSaveOptions.