how to run a macro on document open in writer

Running that other office suite, I used to have macro(s) that ran when I opened certain documents. The macro would display various dialog boxes to prompt the end-user for details that would get inserted into the document. How do I accomplish this withing LibreOffice Writer?

Can I use python to write LibreOffice macro(s) or must I use a BASIC dialect?

For example, I have a facsimile cover page. The macro(s) would prompt for the SEND TO: details, ask for and attach the document(s) to send with the fax, open and count pages within the attached documents, prepare an ATTACHMENTS list, collect SPECIAL INSTRUCTIONS for the cover page, and so on. The macro(s) would then provide a selections dialog to (1) print to paper, (2) print to file, (3) print to fax-printer, and such.

Thanks in advance,

Hello Dan Saint-Andre, to run a macro when the document is opened,

1) select the main menu "Tools:Customize..."
2) in the dialog that pops up, select the tab "Events"
3) There you can attach your macro to the "Document loading finished" event ( or "Open Document" , "Activate Document" , ..  )

And yes, you can also use Python for scripting in LibreOffice. Supported scripting languages are:

LibreOffice Basic
JavaScript
BeanShell
Python

Thanks for the reply and details. I feel like I’ve won the lottery.

FOLLOW-UP – Does anyone have an example document with a fill-in-details prompting macro? As I said in the original post, I used to have these. For reasons I don’t recall (probably scumware related) documents with macros “went away” in the late nineties or early noughties.

e.g. display full path of document in writer’s window title:

Sub setWindowTitle
ThisComponent.setTitle(ConvertFromUrl(ThisComponent.getLocation()))
End Sub