Page 1 of 1 1
Topic Options
#165160 - 2006-07-28 02:38 PM PrintTo UDF can not find file to print
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Guys,

We have a small project that has a requirement to print a bunch of files to a specified printer. It should be completely free of any user actions.

I searched the board and found the PrintTo() - Print any file to any printer UDF. One problem occurs when doing some testing.

I use the script bellow. An error windows pops up telling me that the test.doc file could not be found. Checked, double checked and even triple checked but the file is definitely there and it is accessible. I used .doc and .txt files but all give the same error. Print and printto actions are specified for these file types.

Code:

Break on

$file = "c:\test.doc"
$printer = "\\server\printer"


PrintTo($file,$printer)
If @error
"ERROR OCCURED:" @serror
EndIf



Any idea WTF is happening?
I've seen some other issues with PrintTo but the solutions offered do not give me any joy.

BTW: I'm running this on a WinXPPro SP2 box but in the end it should run on Win2K Server SP4. Using Kix 4.51.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#165161 - 2006-07-29 09:16 PM Re: PrintTo UDF can not find file to print
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Had problems with a similar thing earlier.
Print UDF, error 6 - The handle is invalid

Implemented the suggestion maciep provided in the above thread into the printto udf and now all variables seems to hold the proper values (the path did not have \ characters in it before) and the can not find file popup is gone but still nothing gets printed.

In the above thread I used the print udf to get the dialog box for printing up but when macieps suggestion was implemented it always prints to the default printer and no dialog appears.

I agree that this is a temporarily solution for the current problem but is there anybody that can shed some light on why the printto udf is not working on WinxXP Pro SP2 and Win2K SP4? It would be nice if I could just print to a network printer instead of installing all printers needed and doing a setdefaultprinter in my script each time I need to automatically print a bunch of files to a different printer.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#165162 - 2006-07-29 09:59 PM Re: PrintTo UDF can not find file to print
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
AFAIK to PrintTo() a specific printer, it must first be installed.
Top
#165163 - 2006-07-29 10:11 PM Re: PrintTo UDF can not find file to print
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
I tried it on my home system with the HP DeskJet 6840 installed and connected to one of the USB ports and got the same results. Yesterday I tried to get it to work on a workstation at work that had the HP LaserJet 4050N installed as a network printer. Both cases failed.
Remote printers (installed or not) or local printers do not seem to make any difference.

The fact that the printer needs to be installed I can live with but the numerous setdefaultprinter lines before being able to print to the correct printer really bug me. Right clicking a file and selecting print work fine on both systems so it must be something with the script imho.


Edited by Mart (2006-07-29 10:12 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#165164 - 2006-07-30 10:07 PM Re: PrintTo UDF can not find file to print
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, if it does not work with xp sp2, it's normal.
xp sp2 is so screwed up, that most of the shell controls fail to work properly.

anyways, if it doesn't work on w2k, then it's odd.

Top
#165165 - 2006-07-31 06:36 PM Re: PrintTo UDF can not find file to print
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Looks like the code in the thread below works.
It prints to the default printer and works perfectly on WinXP pro SP2.
Will do some more testing and if all goes ok will post a working (on XP SP2) print UDF later this week.

http://www.adminscripteditor.com/forum/tm.asp?m=7848&mpage=1

It would still be nice if one could print a specified file to a specified printer so all the setdefaultprinter stuff is not needed


Edited by Mart (2006-07-31 06:44 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#165166 - 2006-07-31 06:50 PM Re: PrintTo UDF can not find file to print
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, you saying that the Print() udf does not work either?

hmm...
it's odd that print execute works but printTo doesn't...
you could try changing the printTo() udf to:
Code:

function PrintTo($_file,$_printer)
dim $
$=createobject("shell.application")
$.ShellExecute($_file, $_printer, "", "printto", 0)
exit @error
endfunction


Top
#165167 - 2006-08-01 10:23 AM Re: PrintTo UDF can not find file to print
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
The print UDF sort of works with the change Maciep suggested in the thread linked to above. Only thing is that it does not bring up the printer selection GUI dialog as said in the comments. It just prints to the default printer, no GUI or anything.

The changes to the printto UDF you suggested work great. Just specify a file and a printer and you're done. Thanks

Maybe an update to the original UDF (or a new one) is a good thing.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#165168 - 2006-08-01 10:37 AM Re: PrintTo UDF can not find file to print
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Agree, Jooel's latest works well for me on Server 2003 w/SP1 as well.
Top
#165169 - 2006-08-01 10:44 AM Re: PrintTo UDF can not find file to print
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, will need to update the udf.
odd thing is that it worked originally as MS documents say and now it doesn't.

Top
#165170 - 2006-08-01 11:10 AM Re: PrintTo UDF can not find file to print
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
My guess is that MS changed (f-ed up) something with some patch.

Just did a little test on the server my script should run on when it is all done and it works great (Win2K server SP4).
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#165171 - 2006-08-04 01:59 PM Re: PrintTo UDF can not find file to print
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
See: http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=165607&an=0&page=0&vc=1
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1260 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.105 seconds in which 0.066 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org