[Tutor] Nearly there

John Corry john.corry at ntlword.com
Fri Jan 6 21:40:48 CET 2006


Thanks for all the feedback and help.

The good news is that I have managed to get my windows 98 SE machine to
print a text file using the follwing code:-

import tempfile
import win32api

filename = tempfile.mktemp (".txt")
open (filename, "w").write ("This is a test")
win32api.ShellExecute (
  0,
  "print",
  filename,
  None,
  ".",
  0
)

Can anyone understand or tell me why this works but the following code does
not:-

import win32api
filename = "testprint.txt"
fileobj=open (filename, "w")
fileobj.write ("This is a test")
fileobj.close()
win32api.ShellExecute (
  0,
  "print",
  filename,
  None,
  ".",
  0
)

The code above gives me the error: (31, 'ShellExecute', 'A device attached
to the system is not functioning.')  However this code works fine on the
windows xp + windows 2k.

I am so happy it is like Christmas all over again!

Thanks,

John.



More information about the Tutor mailing list