System.util.execute() to pass parameters into excel file

Hi everyone, I am a shell execute noob. I am trying to run an execute from Ignition to pass a string of 2 numbers into an excel file. in particular this script which i’ve run :


excel.exe /e "c:\Book5.xlsm" /p "3,1"

I’ve tried

commands = ['excel.exe',"C:\Book5.xlsm /p 3,1"]

system.util.execute(commands)
commands = ['excel.exe /e "c:\Book5.xlsm" /p "3,1"']
system.util.execute(commands)

Typically I get an error saying specified file is unable to be found. Any help on this issue would be appreciated!

Backslashes are escapes in python quoted strings. Try doubling them up. Or just switch them to forward slashes.

1 Like

Thanks for the help. I tried but oddly I’m not even able to open an excel file using this:

commands = ['excel.exe' , "C:\\Book5.xlsm"]

I tried doing some sanity checks using .txt files as shown on the Ignition manual for system.util.execute and they passed, however whenever trying to open excel file I get:

Traceback (most recent call last):
  File "<event:actionPerformed>", line 11, in <module>
java.io.IOException: java.io.IOException: Cannot run program "excel.exe": CreateProcess error=2, The system cannot find the file specified

	caused by IOException: Cannot run program "excel.exe": CreateProcess error=2, The system cannot find the file specified
	caused by IOException: CreateProcess error=2, The system cannot find the file specified

You may need to put the full path to excel in there.

1 Like

Thanks guys, both of these solutions were helpful!