AW: Msgbox ausdrucken
02.03.2008 18:46:00
Nepumuk
Hallo Walter,
nicht genauso, aber mit ein bisschen API-Gedöns:
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Private Declare Function MapVirtualKey Lib "user32.dll" Alias "MapVirtualKeyA" ( _
ByVal wCode As Long, _
ByVal wMapType As Long) As Long
Private Declare Sub keybd_event Lib "user32.dll" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Declare Sub Sleep Lib "kernel32.dll" ( _
ByVal dwMilliseconds As Long)
Private Declare Function SetTimer Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Const GC_CLASSNAMEMSEXCEL = "XLMAIN"
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_MENU = &H12
Private hWnd As Long
Private Sub prcPrintMsgBox()
Dim intAltScan As Integer, intIndex As Integer
Call prcStopTimer
Application.ScreenUpdating = False
intAltScan = MapVirtualKey(VK_MENU, 0&)
keybd_event VK_MENU, intAltScan, 0&, 0&
keybd_event vbKeySnapshot, 0&, 0&, 0&
DoEvents
keybd_event VK_MENU, intAltScan, KEYEVENTF_KEYUP, 0&
ThisWorkbook.Worksheets.Add
With ActiveSheet
.Paste
.PrintOut
Application.DisplayAlerts = False
.Delete
Application.DisplayAlerts = True
End With
Application.ScreenUpdating = True
End Sub
Private Sub prcStopTimer()
Call KillTimer(hWnd, 0)
End Sub
Public Sub test()
hWnd = FindWindow(GC_CLASSNAMEMSEXCEL, Application.Caption)
Call SetTimer(hWnd, 0, 100, AddressOf prcPrintMsgBox)
MsgBox "Hallo Walter," & vbLf & "Ich druck mich jetzt mal." & _
vbLf & vbLf & "Deine MsgBox", vbOKOnly, "MsgBox drucken"
End Sub
Gruß
Nepumuk