RPA.Excel.Application().add_files_to_pdf() doesn't work

How can i convert wb to pdf?

2023-05-12 18:09:09:  Traceback (most recent call last):
2023-05-12 18:09:09:    File "/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/RPA/Excel/Application.py", line 28, in catch_com_error
2023-05-12 18:09:09:      yield
2023-05-12 18:09:09:    File "/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/RPA/Excel/Application.py", line 117, in open_application
2023-05-12 18:09:09:      self.app = win32com.client.gencache.EnsureDispatch("Excel.Application")
2023-05-12 18:09:09:  NameError: name 'win32com' is not defined
2023-05-12 18:09:09:  
2023-05-12 18:09:09:  During handling of the above exception, another exception occurred:
2023-05-12 18:09:09:  
2023-05-12 18:09:09:  Traceback (most recent call last):
2023-05-12 18:09:09:    File "/home/worker/instance/runs/29af5ce2-b6e2-428b-a8c9-3b1443e967b1/package/task.py", line 206, in <module>
2023-05-12 18:09:09:      main()
2023-05-12 18:09:09:    File "/home/worker/instance/runs/29af5ce2-b6e2-428b-a8c9-3b1443e967b1/package/task.py", line 196, in main
2023-05-12 18:09:09:      app.export_as_pdf(f'output/{idx}.pdf', f'output/{idx}.xlsx')
2023-05-12 18:09:09:    File "/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/RPA/Excel/Application.py", line 406, in export_as_pdf
2023-05-12 18:09:09:      self.open_workbook(excel_filename)
2023-05-12 18:09:09:    File "/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/RPA/Excel/Application.py", line 165, in open_workbook
2023-05-12 18:09:09:      self.open_application()
2023-05-12 18:09:09:    File "/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/RPA/Excel/Application.py", line 125, in open_application
2023-05-12 18:09:09:      self.app.DisplayAlerts = display_alerts
2023-05-12 18:09:09:    File "/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/contextlib.py", line 137, in __exit__
2023-05-12 18:09:09:      self.gen.throw(typ, value, traceback)
2023-05-12 18:09:09:    File "/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.9/site-packages/RPA/Excel/Application.py", line 29, in catch_com_error
2023-05-12 18:09:09:      except pywintypes.com_error as err:  # pylint: disable=no-member
2023-05-12 18:09:09:  NameError: name 'pywintypes' is not defined
2023-05-12 18:09:09:  Error: exit status 1
2023-05-12 18:09:09:  Task execution completed
2023-05-12 18:09:09:  Uploading artifacts...
2023-05-12 18:09:09:  > 3 artifacts with total size of 150.6 KB
2023-05-12 18:09:09:  - console.txt (139.4 KB)
2023-05-12 18:09:09:  - environment_linux_amd64_freeze.yaml (3 KB)
2023-05-12 18:09:09:  - 0.xlsx (8.2 KB)
2023-05-12 18:09:09:  Activity run completed with status: ERR

Hello,

Where you are trying to run this robot? Also Excel.Application does not have add_files_to_pdf() keyword, did you wanted to use RPA.PDF?

1 Like

Please note, robot is running inside linux container, and there Windows application automation is not available (and no “pywintypes” either, or Excel application either). So that kind of code should not be run on our containers, but it should be run on your own self-hosted windows worker.

See: Find the Worker setup for you | Robocorp documentation

2 Likes