Gruppe
API
Bereich
Drucker
Thema
Drucken der UserForm im Querformat mit Kopfzeile
Problem
Eine UserForm soll im Querformat mit Einstellungen für die Kopfzeile gedruckt werden.
Lösung
Geben Sie den nachfolgenden Code in ein Standardmodul ein und weisen Sie ihn einer Schaltfläche zu.
ClassModule: frmPrint
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdPrint_Click()
Application.ScreenUpdating = False
keybd_event VK_SNAPSHOT, 1, 0, 0
Workbooks.Add 1
ActiveSheet.Range("A1").Select
Application.Wait Now + TimeValue("00:00:01")
ActiveSheet.PasteSpecial _
Format:="Bitmap", _
Link:=False, _
DisplayAsIcon:=False
With ActiveSheet
.PageSetup.Orientation = xlLandscape
.PageSetup.LeftHeader = "Meine UserForm"
.PrintOut
End With
ActiveWorkbook.Close False
Application.ScreenUpdating = True
End Sub
StandardModule: Modul1
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_SNAPSHOT = &H2C
Sub CallForm()
frmPrint.Show
End Sub