Auto run macro on open - can't assign to macro in document

This seems like it should be an easy question, but it has me stumped. I have an .ods file that I converted from an Excel .xls file which had an Auto_Open procedure, and the .ods file now has a Standard Library (in the document), Modules under that, and Module1 under that which contains a Main procedure. If I organize macros, select Module1 and click on Assign, I see that Standard.Module1.Main is assigned to Open Document. Note that at the bottom of the Events dialog it says “Save In” and gives the name of the .ods file that I’m opening and that contains the macro. And sure enough, when I open the document, it runs the macro.

Now I create a brand new Calc document, organize macros, create a new Module1 under Standard, it creates a deafult Main procedure there for me, and I add one line: [msgbox “In Main”]. I can run the macro, but when I go to the Organizer and click Assign, I cannot assign it to the Open Document event. If I click the Assign: Macro button, it only gives me the choice of macros in My Macros or in LibreOffice Macros. If you open the organizer from the IDE, it seems like that the “Save In” box only allows a choice of LibreOffice, and I thought this was the problem. But if I open the organizer from within the Calc document itself, it gives me a choice of the .ods document name in the “Save In” box, but if I try to assign a macro, it STILL only gives me the choice of macros in My Macros or in LibreOffice Macros.

Does anyone know what I am doing wrong?
Thanks, Jeff

OK, I stumbled across a work-around. Note that if I use Tools > Macros > Organize Macros > LibreOffice Basic, then click on the Assign button, I can’t assign any macros from the local document. BUT if I use Tools > Customize, go to the Events tab, click on Open Document, then click the Macro button, I CAN assign a macro from the local document.

I think this is a bug in LO, or at least a bad design decision, so it would be good if someone could note that in the proper places.


Glad I came across your posting as I had a similar problem. I had a Template created in MS Word I wanted to use in LibreOffice. It has an autorun VBA macro. The way you found to assign a macro from the local document works for me too. I was surprised too that the MS VBA code ran without any conversion.


Excellent answer to a perplexing problem. I would upvote, but apparently I’m not allowed. (“New around here” == gag, apparently.)

deleted my q as this thread is closed… have raised a new q.