Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Printing Macro - I need the help of the Alteryx Community

AlexEntz
8 - Asteroid

Hello dear Alteryx Community,

 

I am currently working on building a macro that prints documents directly to the default printer. The macro works, but it has some problems. The Python code I use to execute the printing is pretty small:

 

AlexEntz_0-1652700184478.png

 

The code works when I run it in Python and when I run it in Alteryx while having my default document application open (for example Adobe for PDF files). The macro does not work when I don't have the default program open! I already tried different python libraries such as win32, subprocess and psutils but none of them work.

 

Trying to open the file with the default viewer and then printing also does not work when just using the macro (it does work however if I just execute the python code) Is this a general problem with Python inside Alteryx?

 

I also wrote some code so that you can use any printer, but that code is much more complex and in the end, has the exact same problem this code has. I am looking forward to your suggestions, maybe you can help me find a solution. Many thanks in Advance.

 

Best Regards,


Alex

3 REPLIES 3
IraWatt
17 - Castor
17 - Castor

Hey @AlexEntz,

Not sure why that would be, perhaps the default application to open these files is not set? What is the error? I found an interesting discussion on Stack Overflow on more verbose but hopefully more effective ways to print in python python printing with os.startfile on windows - Stack Overflow.

 

AlexEntz
8 - Asteroid

Hello Ira,

 

like I mentioned in my original post: I also tried usin Win32. It's the same problem: The Python code does not execute properly when run within the alteryx workflow.

 

But thank you for researching, did it work on your machine using the Win32 Library?

 

Best Regards :)

AlexEntz
8 - Asteroid

Hello Again,

 

I solved my own issue. The printing python code only works within a Python SDK, so I basically had to write a Tool for this functionality. I managed to do that, I will post my Solution and yxi Tool as a standalone post!

Labels