Results 1 to 10 of 10

Thread: printer object not working well

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    24

    printer object not working well

    I'm trying to print text and lines to printer using printer object, but not successful. The object is declared as below:
    Dim DrawObj as Object
    Set DrawObj = Printer

    But when I try to print to picture object, it works. It is declared as below:
    Dim DrawObj as Object
    Set DrawObj = Picture1


    Why, and how to solve?

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    not successfull ?

    as in an error occure (if so what)
    as in it prints it all wrong ?

    elaborate
    -= a peet post =-

  3. #3
    Member
    Join Date
    Sep 2001
    Location
    Mexico
    Posts
    33
    i find this hard to explain , so ill give you some sample code for you to look at:

    Private Sub Form_Click()
    Printer.Scale (0, 0)-(850, 1100)
    Printer.Line (100, 100)-(400, 300), , B
    Printer.Circle (425, 550), 300
    Printer.CurrentX = 100
    Printer.CurrentY= 800
    Printer.Print "This is some text."
    Printer.EndDoc
    End Sub

    thisp rints a circle and some text on the sheet

    use the printer object directly (dont try to put it on a variable)

    hope this helps

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Posts
    24
    Nothing printed on the paper from printer.
    No error message.

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    could u show us the sub where u use this object?
    also how u pass the object onto the sub?
    -= a peet post =-

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by Evo
    i find this hard to explain , so ill give you some sample code for you to look at:

    Private Sub Form_Click()
    Printer.Scale (0, 0)-(850, 1100)
    Printer.Line (100, 100)-(400, 300), , B
    Printer.Circle (425, 550), 300
    Printer.CurrentX = 100
    Printer.CurrentY= 800
    Printer.Print "This is some text."
    Printer.EndDoc
    End Sub

    thisp rints a circle and some text on the sheet

    use the printer object directly (dont try to put it on a variable)

    hope this helps
    should not be a problem to assign a printer object to a variable... should it ?
    -= a peet post =-

  7. #7
    Member
    Join Date
    Sep 2001
    Location
    Mexico
    Posts
    33
    i guess not, but , whats the point?

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    if u want to make both print preview and print in the same sub, passing the object u want to print to would be nice I think.
    -= a peet post =-

  9. #9
    Member
    Join Date
    Sep 2001
    Location
    Mexico
    Posts
    33
    good thinking there peet

  10. #10
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    leeek, sample for u.

    this is tested and works just fine.

    In order for u to test it, Start a new vb project
    add a picturebox and to command buttons to the form

    then add this code:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     'Print to printer
    5.     PrintIT Printer
    6. End Sub
    7.  
    8. Private Sub Command2_Click()
    9.     'Print preview to picbox
    10.     PrintIT Picture1
    11. End Sub
    12.  
    13. Private Sub PrintIT(oPrntObj As Object)
    14.     'if this is a picbox for preview, clear it first
    15.     If TypeOf oPrntObj Is PictureBox Then oPrntObj.Cls
    16.    
    17.     oPrntObj.CurrentX = 500
    18.     oPrntObj.CurrentY = 500
    19.     oPrntObj.Print "Testing Testing"
    20.    
    21.     'if u sent it to the printer :
    22.     If TypeOf oPrntObj Is Printer Then oPrntObj.EndDoc
    23. End Sub

    depending on what button u click, it will preview or print.

    hope this can get u off in the right direction
    -= a peet post =-

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