Results 1 to 5 of 5

Thread: Why is'nt this working? [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2002
    Posts
    665

    Why is'nt this working? [RESOLVED]

    I print my form with this code. Everything works, but the checkboxes and commandbuttons are still visible on print out, even if I set the Visible to False? What's wrong?

    VB Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
    2.           ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    3. Private Const VK_MENU As Byte = &H12
    4. Private Const VK_SNAPSHOT As Byte = &H2C
    5. Private Const KEYEVENTF_KEYUP = &H2
    6.  
    7. Private Sub Command3_Click()
    8.  
    9. Clipboard.Clear
    10.  
    11. Me.Check1.Visible = False
    12. Me.Check2.Visible = False
    13. Me.Check3.Visible = False
    14. Me.Command1.Visible = False
    15. Me.Command2.Visible = False
    16.  
    17.  
    18. Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
    19. DoEvents
    20. Call keybd_event(VK_SNAPSHOT, 1, KEYEVENTF_KEYUP, 0)
    21. Printer.Orientation = vbPRORLandscape
    22. Printer.PaperSize = vbPRPSA4
    23. Printer.PrintQuality = vbPRPQHigh
    24.  
    25.     Printer.Print ""
    26.     Printer.Print ""
    27.     Printer.Print ""
    28.     Printer.Print ""
    29.     Printer.Print ""
    30.     Printer.Print ""
    31.     Printer.PaintPicture Clipboard.GetData(), 0, 1000, Printer.width - 1000, Printer.Height - 2800
    32.     Printer.EndDoc
    33.  
    34. Me.Check1.Visible = True
    35. Me.Check2.Visible = True
    36. Me.Check3.Visible = True
    37. Me.Command1.Visible = True
    38. Me.Command2.Visible = True
    39.  
    40. End Sub
    Last edited by Pirre001; Feb 21st, 2004 at 04:45 PM.

  2. #2
    Hyperactive Member temp_12000's Avatar
    Join Date
    Jan 2004
    Location
    LA, USA
    Posts
    411

    Re: Why is'nt this working?

    Originally posted by Pirre001
    I print my form with this code. Everything works, but the checkboxes and commandbuttons are still visible on print out, even if I set the Visible to False? What's wrong?

    maybe try let checkboxes enabled = false?



  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Move them underneath an opaque control

  4. #4
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    lol, or try this:

    VB Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
    2.           ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    3. Private Const VK_MENU As Byte = &H12
    4. Private Const VK_SNAPSHOT As Byte = &H2C
    5. Private Const KEYEVENTF_KEYUP = &H2
    6.  
    7. Private Sub Command3_Click()
    8.  
    9. Clipboard.Clear
    10.  
    11. Me.Check1.Visible = False
    12. Me.Check2.Visible = False
    13. Me.Check3.Visible = False
    14. Me.Command1.Visible = False
    15. Me.Command2.Visible = False
    16. [b]DoEvents[/b]
    17.  
    18. Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
    19. DoEvents
    20. Call keybd_event(VK_SNAPSHOT, 1, KEYEVENTF_KEYUP, 0)
    21.  
    22. Me.Check1.Visible = True
    23. Me.Check2.Visible = True
    24. Me.Check3.Visible = True
    25. Me.Command1.Visible = True
    26. Me.Command2.Visible = True
    27.  
    28. End Sub
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2002
    Posts
    665
    Thanks jemidiah,

    Now it works!

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