Results 1 to 5 of 5

Thread: Printer object valid for devicename, but not for other properties and methods

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    4

    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?

  2. #2
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,309

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    4

    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.

  4. #4
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Printer object valid for devicename, but not for other properties and methods


  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2010
    Posts
    4

    Re: Printer object valid for devicename, but not for other properties and methods

    Quote Originally Posted by Magic Ink View Post
    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
  •  



Click Here to Expand Forum to Full Width