Can't open docx in Word

Good day. We run into problem with LibreOffice make different results on servers.

We run macros to update Table of Content in docx document and make it save, on both servers we have LibreOffice 6.1.4.2 10(Build:2), but 1 server all good, after save we can open document in Word, on other server file corrupted.

All config defaults, we only add 1 macros to run same file, same Ubuntu, run in --headress mode.

@VitaliyLavrenko More Infomration is needed to resolve / help with this question.