I need to convert a .txt file (unicode) file to PDF using libreoffice using AWS lamabda function. It can be achieved using the code found here... https://github.com/fritzpaz/lambda-libre-office/blob/main/main.py#L19 The code is working as expected. And this line is the most important. result = subprocess.run(['/opt/libreoffice7.5/program/soffice', '--headless', '--nologo', '--nodefault', '--nofirststartwizard', '--convert-to', 'pdf', file, '--outdir', '/tmp'], capture_output=True) I need to run a macro before converting the file to PDF. So I added this line just before the one mentioned above. macro_result = subprocess.run( ["/opt/libreoffice7.5/program/soffice", "--headless", "--invisible", "--norestore", f"macro:///StyleLibrary.Module1.myStyleMacro2({file})"], check=False, capture_output=True This line gets executed and changes the file as indicated by timestamp of the file. But the contents of the macro are not actually applied to the text inside the file. I have made sure that the macro is installed through extension. And the macro is working as expected and there is no problem with the macro code. I must be missing something in subprocess.run method. Continue reading...