Consulting

Results 1 to 6 of 6

Thread: Print Userform

  1. #1
    VBAX Newbie
    Joined
    Feb 2019
    Posts
    4
    Location

    Print Userform

    Dear All,

    Greatings...

    I am new to this forum, Is there a way i can print a userform?

    Thanks
    Ahmed

  2. #2
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    382
    Location
    Hi Ahmed!
    UserForm.PrintForm  'You need to change the form name based on the actual situation.

  3. #3
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    598
    Location
    Not sure if this helps, but if you have the userform visible, you can select ctrl-alt-print screen to copy the userform image which you can then paste to a Word document and then print. Dave

  4. #4
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    421
    Location
    .
    Paste this into your UserForm. It will copy the form image to the active sheet. Then you can print from there.

    Option Explicit
    
    
    'Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
    '   bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    'Private Declare PtrSafe Sub keybd_event Lib "User32" _
    '    (ByVal bVk As Byte, ByVal bScan As Byte, _
    '     ByVal dwFlags As Long, ByVal dwExtraInfo As LongPtr)
         
    #If VBA7 Then
        Private Declare PtrSafe Sub keybd_event Lib "user32" _
            (ByVal bVk As Byte, ByVal bScan As Byte, _
             ByVal dwFlags As Long, ByVal dwExtraInfo As LongPtr)
    #Else
        Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
           bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    #End If
         
        
        
    Private Const KEYEVENTF_KEYUP = &H2
    Private Const VK_SNAPSHOT = &H2C
    Private Const VK_MENU = &H12 '''
    
    
    Private Sub AltPrintScreen()
            keybd_event VK_MENU, 0, 0, 0
            keybd_event VK_SNAPSHOT, 0, 0, 0
            keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
            keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
    End Sub
    Private Sub CommandButton1_Click()
    Call AltPrintScreen
        DoEvents
        Application.Wait Now + TimeSerial(0, 0, 1)
        Worksheets("Sheet1").Range("B3").PasteSpecial
        Unload Me
    End Sub

  5. #5
    VBAX Newbie
    Joined
    Feb 2019
    Posts
    4
    Location
    Thank you all for your help.

  6. #6
    VBAX Mentor Logit's Avatar
    Joined
    Sep 2016
    Posts
    421
    Location
    .
    You are welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •