Thanks for looking into this for me Tim.
Unfortunately, my code is essentially the same as yours but it does not switch the output from my A4 printer to the label printer as I had hoped it would.
Here is my code:
dim sql as string
dim rsPrinterSetup as RecordSet
dim page as Graphics
dim ps as PrinterSetup
dim settings as string
sql = "SELECT LabelPrinter FROM PrinterSetup"
rsPrinterSetup = db.SQLSelect(sql)
settings = rsPrinterSetup.Field("LabelPrinter").StringValue
'set up the printer with settings retrieved from the database
ps = new PrinterSetup
ps.SetupString = settings
ps.MaxVerticalResolution = 600
ps.MaxHorizontalResolution = 600
page = OpenPrinter(ps) 'open the printer and get the page graphics object for our layout
My printer settings are stored in a database in a one-line table called "PrinterSetup" and the table has two columns called "LabelPrinter" and "A4Printer". Separate code presents the PageSetupDialog of the PrinterSetup class to the user and stores the respective strings in the database. I have carefully verified that the correct strings are stored in their respective fields in the database.
If for testing purposes I change
page = OpenPrinter(ps)
into
page = OpenPrinterDialog(ps)
then the dialog presents the A4 printer as the default printer and this is where the print ends up going if I just use OpenPrinter.
If at the printer dialog I leave the setting for the A4 printer and choose the Preview button rather than the Print button, my label is correctly displayed, demonstrating that the Graphics object created by
page = OpenPrinter(ps)
has the dimensions and characteristics of the LabelPrinter specification as I would expect, BUT the print is still sent to the A4 printer.
At the moment the only way I can get the printing sent to the correct printer is by presenting the user with a print dialog and in effect, change the printer by manual intervention rather than under the control of my program (very frustrating). If you (or any other) can spot an error in my program logic, I'd be most grateful to know of it.
Thanks
jamesee
