AW: wurde gedruckt?
25.09.2020 11:09:06
Nepumuk
Hallo Hans,
bei mir wird die Event-Prozedur nur ausgelöst wenn ich wirklich drucke, nicht durch die Seitenansicht. Du kannst ja eine eigene Property anlegen in der du das Datum des Drucks einträgst.
Im Modul "DieseArbeitsmappe":
Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim objDocumentProperty As DocumentProperty
For Each objDocumentProperty In CustomDocumentProperties
If objDocumentProperty.Name = PRINT_DATE Then Exit For
Next
If objDocumentProperty Is Nothing Then
Call CustomDocumentProperties.Add(Name:="PrintDate", _
LinkToContent:=False, Type:=msoPropertyTypeDate, Value:=Now)
Else
objDocumentProperty.Value = Now
Set objDocumentProperty = Nothing
End If
End Sub
In einem Standardmodul (Menüleiste - Einfügen - Modul):
Option Explicit
Public Const PRINT_DATE As String = "PrintDate"
Public Sub GetLastPrintDate()
Dim objDocumentProperty As DocumentProperty
For Each objDocumentProperty In ThisWorkbook.CustomDocumentProperties
If objDocumentProperty.Name = PRINT_DATE Then Exit For
Next
If objDocumentProperty Is Nothing Then
Call MsgBox("Dokument wurde noch nicht gedruckt.", vbExclamation, "Hinweis")
Else
Call MsgBox(Format$(objDocumentProperty.Value, "dd.mm.yyyy Hh:Nn:Ss"), vbInformation, "Information")
Set objDocumentProperty = Nothing
End If
End Sub
Gruß
Nepumuk