If for any reason the actual printer name changes, you will have to hardcode it again later. What will always be in the name? Try something like:
clear
lcOldPrinter = SET('PRINTER',2)
lcOldPrinterf = SET('PRINTER',3)
? SET('PRINTER',2)
? SET('PRINTER',3)
? "*****************"
=APRINTERS(myprinters)
for i = 1 TO ALEN(myprinters,1)
IF "ZEBRA" $ UPPER(myprinters(i,1))
SET PRINTER TO NAME (myprinters(i,1))
=SetPrinter(myprinters(i,1))
EXIT
ENDIF
ENDFOR
? SET('PRINTER',2)
? SET('PRINTER',3)
? "*****************"
set printer to name (lcoldprinterf)
=SetPrinter(lcoldprinter)
? SET('PRINTER',2)
? SET('PRINTER',3)
? "*****************"
RETURN
FUNCTION setPrinter
LPARAMETERS cprinter
IF !EMPTY(cPrinter)
DECLARE Integer SetDefaultPrinter IN WINSPOOL.DRV String
IF SetDefaultPrinter(cPrinter) = 0
=MESSAGEBOX("Cannot change default Windows Printer")
ENDIF
ENDIF
>I created code to get and set the windows default printer, as per code and other threads on here (UT).
>(I need to do this because the driver for my Zebra S600 printer doesn't work right if the printer is not the default)
>
>Each workstation on my customer's network shares the label printer. I have hardcoded the share name: '\\BUD3\Zebra Stripe 600' as the printer to set default to when they want to print from my label printing application.
>This works fine when the user is on a workstation on the network. But if the user is on the local machine.. the printer name is 'Zebra Stripe 600' (without the machine name).
>
>I tried to get windows to treat the printer as a network printer,even though it is on the local machine, but windows doesn't see to do want to do this. I tried adding the printer as a network printer, even though it was already installed as local, but windows (win2k pro) won't make a second instance of the printer.
>
>I ended up writing code in the app to check to see what user/workstation is in use, and if the local machine that the printer is on - then set the printer name without the machine name.
>
>Any suggestions appreciated.
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"