CartoonDog
IS-IT--Management
Hi, I know how to set the printer object in VB code by matching the device name. Such as
---------------
dim x as printer
for each x in printers
if x.devicename="YourPrinterName" then set printer=x
next
--------------
But I have written an app that requires the program to set the printer to different printers depending on which type of form they are trying to print. (Different forms on different printers). To make it easy on the users, I want the program to select the printer without the users intervention. I have been able to do this by storing the printer name in a database and refering to it when they need to print to that printer. Ok, so whats the problem? This is a cheesy method. What if the user renames the printer in the control panel? Also the statement 'Set Printer=x' You would think that x would evaluate to some index that could be saved so that if its devicename was renamed, it could still be refered to.
One thing that might work, but I have some missing gaps in my knowledge of how VB hDCs work. Could the hDC be used in some fashion? VB help states that the OS could change the hDC. So if the user rebooted, would it remain the same for all time? I dont know?
The last method I tried was to use the index in the printers collection. This fails because the numbers are sequential and not static. If a user deletes a printer (assuming its not the last) all the indexs adjust.
Perhaps there is a simple method I am overlooking? Help if you can, thanks. CartoonDog.
---------------
dim x as printer
for each x in printers
if x.devicename="YourPrinterName" then set printer=x
next
--------------
But I have written an app that requires the program to set the printer to different printers depending on which type of form they are trying to print. (Different forms on different printers). To make it easy on the users, I want the program to select the printer without the users intervention. I have been able to do this by storing the printer name in a database and refering to it when they need to print to that printer. Ok, so whats the problem? This is a cheesy method. What if the user renames the printer in the control panel? Also the statement 'Set Printer=x' You would think that x would evaluate to some index that could be saved so that if its devicename was renamed, it could still be refered to.
One thing that might work, but I have some missing gaps in my knowledge of how VB hDCs work. Could the hDC be used in some fashion? VB help states that the OS could change the hDC. So if the user rebooted, would it remain the same for all time? I dont know?
The last method I tried was to use the index in the printers collection. This fails because the numbers are sequential and not static. If a user deletes a printer (assuming its not the last) all the indexs adjust.
Perhaps there is a simple method I am overlooking? Help if you can, thanks. CartoonDog.