Hooking "Save/Save as" functionality

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Nimral
Posts: 4
Joined: Thu Dec 01, 2016 12:29 pm

Hooking "Save/Save as" functionality

Post by Nimral »

Hi all,

does OO Basic provide any means to globally hook into the save / save as functionality?

What I need to do is to create a global macro which inspects all file save operations, and, if a file is to be saved into a specific directory (e.g. ...\my documents\reports) it will automatically create a filename (derived from the current date and time to ensure uniqueness) and save the file without any further user interaction, whereas, if the file is to be saved anywhere else, the default Open Office file save behaviour is retained.

Can such low-level programming be done in Open Office Basic or Libre Office Basic?

Thnx, Armin.
Open Office 4.1.2 on Windows 10
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: Hooking "Save/Save as" functionality

Post by JeJe »

See Useful Macro Information
For OpenOffice
By
Andrew Pitonyak

Listing: Intercept menu commands using Basic

https://www.pitonyak.org/oo.php
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
LibreOfficiant
Posts: 12
Joined: Wed Jan 25, 2017 9:36 pm

Re: Hooking "Save/Save as" functionality

Post by LibreOfficiant »

See "Monitoring document events" in TDF wiki macros page at https://wiki.documentfoundation.org/Macros/General
libO 5.4 64bit, (PortableApps: libO 6.0, aOO 4.1, OOo 3.2 32bit) on Win7/Win10 x64 | aOO 4.1.x & libO 5.4.x on Mint 18 Sarah & OSX 10.9 Mavericks x64
Python toolbox: Geany, PyCharm and APSO, MRI extensions..
https://wiki.documentfoundation.org/Macros/Design_Guide
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Hooking "Save/Save as" functionality

Post by RoryOF »

How would the Macro decide on the destination of the file? If it extracted the filename extension, it would know the destination, but that presupposes a filename. If the destination is decided by the internal OO file type (Writer, calc etc), well and good. Would that work if files were being working in foreign (i.e., non OpenOffice) formats?
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: Hooking "Save/Save as" functionality

Post by JeJe »

This is an old thread from 2021 - and I gave a poor answer (Apologies) and it was the only one given.

Tools menu/customise/Events has several relating to document saving which can be global to OpenOffice which could be investigated.

"Document has been saved as" presumably would allow actions depending on which folder saved to.

The OP has perhaps had this resolved themselves or elsewhere or moved on...
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply