Ask Your Question
0

warning: event triggers macro in other/wrong document [closed]

asked 2015-03-27 01:26:58 +0200

LibreGuy gravatar image

updated 2015-08-28 13:25:49 +0200

Alex Kemp gravatar image

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

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by doug
close date 2017-01-02 19:01:40.576887

Comments

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

LibreGuy gravatar imageLibreGuy ( 2015-03-29 11:19:56 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2015-03-27 15:29:11 +0200

LibreGuy gravatar image

updated 2015-03-27 15:35:51 +0200

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.

2.

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

3.

  • 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.

4.

  • 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.

edit flag offensive delete link more

Comments

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 ?
karolus gravatar imagekarolus ( 2015-03-27 16:08:29 +0200 )edit
  1. Did you store the linked Makro into test.ods ? No, I stored it in Module1 (My Macros).
    1. Did you save the event-link also in test.ods ? Yes, I did.
LibreGuy gravatar imageLibreGuy ( 2015-03-27 16:19:24 +0200 )edit

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

karolus gravatar imagekarolus ( 2015-03-27 16:51:23 +0200 )edit

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?

LibreGuy gravatar imageLibreGuy ( 2015-03-27 17:21:53 +0200 )edit
0

answered 2015-03-27 11:51:22 +0200

karolus gravatar image

I cannot reproduce that Issue

we need Example-docs, Makrocode....

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-03-27 01:26:58 +0200

Seen: 236 times

Last updated: Mar 27 '15