Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting printer and tray by IP address at runtime 2

Status
Not open for further replies.

CMcC

Programmer
Feb 5, 2002
196
US
Hi-
I have a report form in VFP 7.0.
I need to be able to select a printer at runtime by a specific IP address as well as selecting tray 2 at the same time.
Reason:
4 offices in different locations.
Each has a laser HP2200 defined by IP on NOvell Network.
Instead of creating 4 different reports and changing the printer and tray though page setup, I would like to programmatically call the appropriate printer by knowing which office is using the program.
Is this possible?

Please - any suggestions welcome.
thanks
Carol
 
Hi Dave-

All branches have the same "printer name", but different IP addresses. Im not sure how to call the printer by IP address through, and really dont know how to address the second tray of the printer at runtime (only through page setup in the report form can you select which tray - that I know of).
I want to stay away from having to create 4 reports and changing the printer name in each one.

any other suggestions?
thanks
Carol
 
I guess I'm confused. Are these printers on a WAN? If they are all on the same network, they can't have the same name, unless maybe they are on different servers.
If they are, you would set the printer by using:
SET PRINTER TO NAME \\ServerName\PrinterName

If they are not, and they all have the same name, you just call the printer by name.

As for setting the tray, you should just do it in the page setup.
If you do it at run time, you need to make sure the line which reads DEFAULTSOURCE has a vlue of 2. For example:
DEFAULTSOURCE=2

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
>> Are these printers on a WAN?
yes.

>>they can't have the same name, unless maybe they are on different servers.

they are on different 'segments' of the WAN - addressed by IP.


so to issue by IP address, Could I do this:

SET PRINTER TO NAME \\IPADDRESS?

Thanks Dave.
Carol
 
You may be able to do something like:
SET PRINTER TO NAME \\ServerName\IPADDRESS

Something differentiates one printer from another. Maybe you could use the port instead of the printer name if the above don't work.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Dave -
I will try your suggestion and see what comes of it.
I will post the results soon.

thanks
carol
 
Hi Dave-
heres the code:

Do Case
Case ag_num = "1"
machinename = "\\10.10.21.85\"
Case ag_num = "2"
machinename = "\\10.10.22.85\"
Case ag_num = "3"
machinename = "\\10.10.23.85\"
Case ag_num = "4"
machinename = "\\10.10.24.85\"
ENDCASE

lcComm = ;
"SET PRINTER TO NAME '" + Alltrim(machinename) + "'"
&lcComm




Not working - getting 'error accessing printer spooler"

Here is the breakdown.
>>SET PRINTER TO NAME \\ServerName\IPADDRESS
We are not using the Microsoft printer server setup, we have 'Jet Direct' printers that we call from the network....
so there really isnt a 'ServerName' to call to.

Do you know anything about the jetDirect setups?

This has got to work somehow.
Thanks
Carol
 
Hi Dave-
Got it. had to put the "/" after the IP address as such:

Do Case
Case ag_num = "1"
machinename = "\\10.10.21.85\"
Case ag_num = "2"
machinename = "\\10.10.22.85\"
Case ag_num = "3"
machinename = "\\10.10.23.85\"
Case ag_num = "4"
machinename = "\\10.10.24.85\"
ENDCASE

lcComm = ;
"SET PRINTER TO NAME '" + Alltrim(machinename) + "'"
&lcComm


Thanks for all your help!
 
Hi Dave-
yeah, I added the "\" in the previous post, but actually did not have the "\" in my prog code. That tipped me off there....the first post should have been

Case ag_num = "1"
machinename = "\\10.10.21.85"


it sure is Tuesday!
Have a great week.
Carol
 
I spoke too soon.
Now, when I built the .exe, Im getting the spooler error again...
seems like it is on the code:

lcComm = ;
"SET PRINTER TO NAME '" + Alltrim(machinename) + "'"

---------> &lcComm


as soon as it gets to this last line, is where the error is....
ugh.

Thanks -
Carol
 
Ok, got past the error, although now, even though I have changed the EXPR field in all reports to say:

DRIVER=winspool
DEVICE=HP LaserJet 2100 Series
OUTPUT=HPLaserJet2100Series
ORIENTATION=0
PAPERSIZE=1
ASCII=1
COPIES=1
DEFAULTSOURCE=257 (tray #3? - I selected thru page setup)
PRINTQUALITY=600
COLOR=1
YRESOLUTION=600
TTOPTION=3
COLLATE=1


Still - prints to my LPT1 - not the network printer by 10.10.21.85.

Should I have:
DEVICE=HP LaserJet 2100 Series
OUTPUT=HPLaserJet2100Series

or should I have the IP address, (or machinename), but can I call a variable within the EXPR field of the report table?

This is crazy.
Thanks
carol
 
Hi Carol,

FYI: The code you quoted like:
Code:
lcComm = ;
"SET PRINTER TO NAME '" + Alltrim(machinename) + "'"
   --------->    &lcComm
Should also work with a "name expression" like this:
Code:
SET PRINTER TO NAME (Alltrim(machinename))

It doesn't make a big difference in your code here, but when executed in a loop the speed difference betwee "name expressions" and macro replacement can be tremendous.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top