warning: event triggers macro in other/wrong document

I created a macro for certain type of documents. This macro checks, and if necessary changes, some properties of a document. I assigned (Tools->Customize->Events) this specific macro to the “Save Document” and “Save Document As” events and saved these settings in the document itself (so NOT in LO).

Sometimes I’m working on 2 documents at the same time. I have the “auto-save” option enabled. Now what happens is that I’m working in document A and all of a sudden I see that within this document, the assigned macro from document B is being triggered, affecting the properties of document A (my document properties got screwed)! So document B is unintentionally changing document A. What I think happens is that document B is being auto-saved which triggers the (“Save Document”) macro … which, by mistake, is executed in document A (since that document is open at the same time). So in short, a macro from another open document fires in the current document, because the other document is being auto-saved. Seems like a serious error.

Windows 7, version: 4.4.1.2

Can anyone please try to test this and confirm (or not) this behavior?

I cannot reproduce that Issue

we need Example-docs, Makrocode…

Allright … I tried te set up a scenario in which the problem occurs. Please follow these exact steps:
(It might look a bit complicated, but it’s quite easy actually.)

  • Go to Tools->Options->Load/Save->General
  • Set “Save AutoRecovery information every:” to 1 minutes
  • Also make sure “Automatically save the document too” is enabled.

Create (copy/paste) this macro:

REM Test Macro

Sub Test

DOC   = ThisComponent
PROPS = DOC.DocumentProperties

If PROPS.Title = "" Then
    NewTitle    = InputBox("Enter document title:")
    PROPS.Title = NewTitle
End If    

End Sub
  • Start LO and create a new CALC document.
  • Save the document on your dekstop as “test.ods”.
  • Go to Tools->Customize->Events
  • Assign the macro “Test” (see step 2) to the “Save Document” event.
  • Now save the document by pushing the “Save” button or pressing CTRL+S.
  • A popup box will appear. Enter the document title “test”.
    (If you go to File->Properties->Description you will see the title has changed to “test”.)
  • Save the document and close it.
  • Start LO and create a new CALC document (do NOT save this document).
  • Enter the letter “a” in cell A1 and then select cell A2.
  • Open “test.ods” from your desktop.
  • Also in this file, enter the letter “a” in cell A1 and then select cell A2.
  • Now go to the unsaved document (Untitled 1.ods).
  • Wait, and within a minute a popup box will appear. Enter the document title “test 2”.
  • Go to File->Properties->Description and you will see the title has changed to “test 2” while the macro was not assigned to this document.

Please let me know if you could reproduce this behavior.

No, can’t reproduce,

  1. Did you store the linked Makro into test.ods ?
  2. Did you save the event-link also in test.ods ?
  1. Did you store the linked Makro into test.ods ? No, I stored it in Module1 (My Macros).
  2. Did you save the event-link also in test.ods ? Yes, I did.

Keep sure the event is not registered twice, once in test.ods once in LibreOffice ??

I’m positive it’s only registered to test.ods. I don’t have any events registered to LO. Did you exactly as I explained?