|
-
Mar 18th, 2016, 10:36 AM
#1
Thread Starter
New Member
Printer object valid for devicename, but not for other properties and methods
I am trying to modify some code that was written by a previous employee. The code saves the default printer (prt-x), changes the default to a different printer (prt-y), prints a label, then changes back to the original default printer (prt-x). My modification is to check the customer, and for 1 customer, change the default to printer prt-z, but for all others change to prt-y. In both cases, the original default printer is restored. The code has not problem changing the default printer. But when the sub is called to print the label, the "Printer.DeviceName" is valid, but all other properties give me an run-time error 482. When I debug, I get that all the properties (except DeviceName) have a printer error (e.g., the Printer.ScaleMode=<printer error>).
Here is the PrintLabel sub:
Private Sub PrintLabel(ByVal Customer As String)
Debug.Print Printer.DeviceName
If Customer <> "99131" Then
Canvas.ObjDraw1.UnSelectAll
Printer.ScaleMode = 1
Printer.Width = 4 * 1440
Printer.Height = 6 * 1440
Printer.ColorMode = 1
Printer.PaintPicture Canvas.ObjDraw1.Image, 0, 0, Printer.Width, Printer.Height
Printer.EndDoc
Else
Canvas2.ObjDraw1.UnSelectAll
Printer.ScaleMode = 1
Printer.Width = 4 * 1440
Printer.Height = 1.5 * 1440
Printer.ColorMode = 1
Printer.PaintPicture Canvas.ObjDraw1.Image, 0, 0, Printer.Width, Printer.Height
Printer.EndDoc
End If
End Sub
More info: The label printer that I am trying to print to is shared on a different computer (computer name = "FPMCUPS3"). The printer name is "ItemLabels", and the Printer.DeviceName returns "\\FPMCUPS3\ItemLabels".
Can anybody help me determine why I am getting <printer error> for all the properties, except for DeviceName?
-
Mar 20th, 2016, 04:18 AM
#2
Re: Printer object valid for devicename, but not for other properties and methods
You can't set some properties because they are read only. Use a picturebox and then copy to printer, resizing and moving where you decide.
-
Mar 21st, 2016, 08:34 AM
#3
Thread Starter
New Member
Re: Printer object valid for devicename, but not for other properties and methods
Thank you for your response. However, my modification added an "if-then-else" around the first set of printer properties. I.e. the original code set the printer width and height, I just changed the size based on a customer. Also, now even the original code does not work when running in debug mode, although the compiled version runs fine.
-
Mar 21st, 2016, 02:57 PM
#4
Re: Printer object valid for devicename, but not for other properties and methods
-
Mar 22nd, 2016, 07:14 AM
#5
Thread Starter
New Member
Re: Printer object valid for devicename, but not for other properties and methods
 Originally Posted by Magic Ink
Thank you, Magic Ink. That looks promising.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|