Hi guys,
I would like to print my UserForm using PrintForm.
I found the following code at VBForums. When I try to run it at Printer.Print erites me 424 error code. Could anybody help me?
Thanks
Boris
VB Code:
Option Explicit 'settings for Print.Screen Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _ ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Public Const VK_MENU As Byte = &H12 Public Const VK_SNAPSHOT As Byte = &H2C Public Const KEYEVENTF_KEYUP = &H2 Public Sub Image5_Click() Printscreen End Sub Public Sub Printscreen() Dim lWidth As Long, lHeight As Long 'Clipboard.Clear Application.CutCopyMode = False Call keybd_event(VK_MENU, 0, 0, 0) Call keybd_event(VK_SNAPSHOT, 0, 0, 0) DoEvents Call keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0) Call keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0) Printer.Print If Width > Printer.ScaleWidth Then lWidth = Printer.ScaleWidth lHeight = (Printer.ScaleWidth / Width) * Height Else lWidth = Width lHeight = Height End If Printer.PaintPicture Clipboard.GetData, 0, 0, lWidth, lHeight Printer.EndDoc End Sub




Reply With Quote