Python Script calling macro no longer works after LO update


I have a python script that I run every day. At the very end, it runs a macro whose job it is to pull data into a template file and save it with a specific name passed to the macro by the python script. Yesterday at the end of the day, I upgraded LO from 5 to 7. This morning, the script no longer works. (The macro isn’t doing what I need it to.) I call the script from the command prompt. Here are my python script and macro, as well as the error messages I’m getting. The line numbers in the errors don’t mean anything to me. (To upload the python script, I had to copy and paste its contents into a .odt file, so I went ahead and stashed the macro in that file. (On my system, the macro is not in any file, but at the top level.))

Sorting Logs.odt (19.1 KB)

The error is written at the end of the screenshot: file not found (probably soffice isn’t in a PATH directory).

Arg! I tried adding the path for the LO apps to the path variable, but now it’s broken because pyautogui won’t import, since adding that made it default to python 2 instead of python 3. The actual problem was that in my python script “soffice” was specifically targeting Calc 5, not 7. Since I added the directory for the latest LO to the system path, when I run the python command from the command prompt, it defaults to Python2, not Python 3. Anyone know how to fix this?

I guess you may replace the “soffice” in your script with the real path of the libreoffice inatallation. For instance., “C:\Program Files/libreoffice/program/soffice.exe”

Two nitpicks.

  1. You forgot to replace the first backslash with the forward slash :wink:
  2. It’s preferable to not use soffice.exe where some batch processing is executed, because there’s a soffice.com for that purpose, correctly handling stdin/stdout/stderr, available since 6.3.

Sorry, have been in linux for 10 years and thus not familar with the win path pattern.

No need to be sorry :slight_smile:
The problem here is not the proper pattern on Windows (in fact, the proper separator there is backslash, and the forward slash is permitted in some contexts as an alternative). The problem is rather python syntax, where you need to either mask the backslash (otherwise you get at lease a warning), or use other special methods to treat backslash literally, like binary. That’s why I mentioned that here.

Thanks to all of you for your help. Backslash…forward slash…I wish the windows world were as simple as the linux world. I’ve been using linux exclusively for my PC at home for 18 years. Unfortunately, here at work, I’m stuck with software that is only available for Windows.

Also, because of Mike’s input, I’ve been able to get the script/macro combo working as intended.