diff --git a/src/frontend/app/viewer/document-viewer.component.ts b/src/frontend/app/viewer/document-viewer.component.ts
index e2a13fa69a99cf4485be072644a0bdc4cb06bf8b..a44e3dfb118837143b47bafad412d295819f818e 100755
--- a/src/frontend/app/viewer/document-viewer.component.ts
+++ b/src/frontend/app/viewer/document-viewer.component.ts
@@ -873,7 +873,7 @@ export class DocumentViewerComponent implements OnInit, OnDestroy {
                         this.editInProgress = false;
                         clearInterval(this.intervalLockFile);
                         await this.loadTmpFile(`${data.fileTrunk}.${extension}`);
-                        if (this.mode === 'mainDocument') {
+                        if (this.mode === 'mainDocument' && this.resId !== null) {
                             this.saveMainDocument();
                         }
                     }