Issue with UNO API in Python Macro for Copying Data Between .ods Files

'm encountering an issue with a Python macro intended to copy data from several .ods files into a master file using the LibreOffice UNO API. The macro is supposed to loop through a dictionary of file paths, open each file, copy a range from a sheet named “Diary” to a corresponding sheet in the master file, and then log the number of sheets in the source file to a specific cell in the master file. The script executes as expected for the first file in the dictionary, but fails for all subsequent files with the same error. No data is copied, and the expected log messages are not written.

Error Message:

vbnet

An error occurred while copying data to sheet 'SheetName': at ./sc/source/ui/unoobj/docuno.cxx:4033

Script Behavior:

  • The first file is always processed correctly, regardless of its order in the dictionary.
  • Subsequent files are opened, but the data is not copied, and no errors are logged in the master file.

Environment:

  • LibreOffice version: [7.6.5.2]
  • Operating System: [Ubuntu 23.10]

Steps Already Taken:

  • Ensured file names and paths are case-sensitive and match exactly.
  • Added delays between file processing and implemented garbage collection.
  • Attempted to explicitly check and handle open documents.
  • Searched for LibreOffice logs for further insights.

Questions:

  1. Is there a known issue with the UNO API that could cause this behavior?
  2. Are there additional steps I can take to debug or resolve this issue?
  3. Could there be an issue with how the UNO API manages open documents or with the document model itself?

Any advice or guidance would be greatly appreciated, as I’ve exhausted my debugging options and am unsure how to proceed.

Maybe ask on a libreoffice mailing list or forum?
This is a libreoffice issue you are asking for help with.

1 Like