Results 1 to 17 of 17

Thread: printing two texts at with one click

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    printing two texts at with one click

    Hello

    how can i print two richtexts using only one click buttun

    i have to let user decide if he wants to print one of the texts or both by a check box

    once he choose the text or texts and click (print) they should be printed in the same format and color of the original texts and in saparate papers

    thanks all

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: printing two texts at with one click

    VB Code:
    1. if chk1 then RichTextBox1.SelPrint(Printer.hDC)
    2. if chk2 then RichTextBox2.SelPrint(Printer.hDC)
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: printing two texts at with one click

    it gives an error
    (Method or data member not found)
    and points to (.SelPrint)

    should i add something from components

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: printing two texts at with one click

    what is the name of your rich text controls?
    or are you trying to print .rtf files, if you want to print files, you will need to use shellexecute to use the associated program (normally ms word, but if word not installed then wordpad) to print the file
    alternativly you can load the file contents into a rich text control then use the selprint method
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: printing two texts at with one click

    actually they r not files

    they r two normal richtexts in two different forms
    one is txtFileText in a form (main)
    second is RichTextBox1 in a form (form1)

  6. #6
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: printing two texts at with one click

    Try this:
    VB Code:
    1. if chk1 then [B]main.txtFileText[/B].SelPrint(Printer.hDC)
    2. if chk2 then [B]form1.RichTextBox1[/B].SelPrint(Printer.hDC)

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: printing two texts at with one click

    Yes gavio i tried exactly what you wrote
    but it gives an error as i said

  8. #8

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: printing two texts at with one click

    is txtfiletext a text box, or richtextbox?
    you can't use selprint on a standard text box
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: printing two texts at with one click

    they are richtext boxes

    simplly there is two forms each with a different richtext box and i need to let the user to choose if he want to print one of them or both by a checkbox


    i mean:

    print form should include:

    checkbox 1 is for the first text
    checkbox 2 for the second

    and one print button

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: printing two texts at with one click

    well the selprint should work, as you have posted no code or any example i am unable to help any further
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  12. #12
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: printing two texts at with one click

    Are your richtextboxes either accidently or on purpose in a control array? (You can check by looking at the Index property which will be 0 or greater if they are). If so then you need to do something like

    VB Code:
    1. if chk1 then RichTextBox(0).SelPrint(Printer.hDC)
    2. if chk2 then RichTextBox(1).SelPrint(Printer.hDC)

  13. #13
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: printing two texts at with one click

    Are your richtextboxes either accidently or on purpose in a control array?
    he say they are on different forms

    one is txtFileText in a form (main)
    second is RichTextBox1 in a form (form1)
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  14. #14

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: printing two texts at with one click

    so......

  16. #16
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: printing two texts at with one click

    zip your project and post if you want someone to look at it
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  17. #17

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