سؤال

Is there a way to automate these steps?

  • open a LibreOffice ODT
  • update the TOC and other fields (e.g. via menu Tools|Update|Update All)
  • save and close the document
هل كانت مفيدة؟

المحلول

If you're using Windows, then this can be achieved very easily using Automa:

start("LibreOffice", r"c:\path\to\your\document.odt")
press(ALT + 't', 'u', 'u')
press(CTRL + 's')
press(ALT + F4)

You can save these 4 lines to a text file with the .at extension and play it back using Automa whenever required.

If you would like Automa to be able to find labels, click on menus etc. you need to go to Tools|Options|LibreOffice|Accessibility and tick the "Support assistive technology tools (program restart required)" checkbox. Then, for example the following will be possible:

start("LibreOffice", r"c:\path\to\your\document.odt")
click("Tools", "Update", "Update All")
press(CTRL + 's')
press(ALT + F4)

Disclaimer: I'm one of the Automa developers

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top