Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1160to1164
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Zugriff & Änderung von Exceldateien protokollieren

Zugriff & Änderung von Exceldateien protokollieren
Exceldateien
Hallo,
zuerst vielen Dank für die vielen Hilfen hier im Forum auf meine bisher gestellten Fragen, wirklich SUPER, DANKE !
Ich bitte um Hilfe zu folgendem Problem :
Ich schreibe in eine Textdatei die Zugriffe auf eine Exceldatei wie folgt :
in "DieseArbeitsmappe" steht :

Option Explicit
Private Sub Workbook_Open()
protocol
End Sub

im Modul mod_prot steht :

'   Modul mod_prot
Option Explicit
'   Variablen setzen
Public myApp As New cls_pro
Sub protocol()
Set myApp.App = Application
End Sub
Public Sub protocol1(BENUTZER As String, DATUM As String, _
UHRZEIT As String, DATEINAME As String, Modus As String)
Open "E:\_EIGENE\ZUGRIFFE.txt" For Append As #1
Print #1, BENUTZER & vbTab & DATUM & vbTab _
& UHRZEIT & vbTab & DATEINAME & vbTab; Modus
Close #1
End Sub

im Klassenmodul steht :

'   Klassenmodul cls_pro
Option Explicit
'   Variablen setzen
Public WithEvents App As Application
Private Sub App_WorkbookBeforeClose _
(ByVal Wb As Workbook, Cancel As Boolean)
protocol1 Application.UserName, Format(Now, "DD.MM.YYYY"), _
Format(Now, "HH:MM:SS"), Wb.FullName, "ENDE"
End Sub
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
protocol1 Application.UserName, Format(Now, "DD.MM.YYYY"), _
Format(Now, "HH:MM:SS"), Wb.FullName, "START"
End Sub

damit werden in die Datei Zugriffe.txt alle Start und Ende geschrieben.
Nun möchte ich folgende Ausgabe der Msgbox aus dem Klassenmodul in die Textdatei z.B. aender. _
txt schreiben, die Ausgabe in einer Msgbox klappt, wie bekomme ich die Informationen der Msgbox _
in eine Textdatei. Msgbox wird wie folgt erstellt :

'   Klassenmodul cls_pro
Option Explicit
'   Variablen setzen
Public WithEvents App As Application
Private Sub App_WorkbookBeforeClose _
(ByVal Wb As Workbook, Cancel As Boolean)
protocol1 Application.UserName, Format(Now, "DD.MM.YYYY"), _
Format(Now, "HH:MM:SS"), Wb.FullName, "ENDE"
End Sub
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
protocol1 Application.UserName, Format(Now, "DD.MM.YYYY"), _
Format(Now, "HH:MM:SS"), Wb.FullName, "START"
End Sub
Private Sub App_SheetChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)
MsgBox "Zelle " & Target.Address(False, False) & _
" aus Blatt " & ActiveSheet.name & _
" aus Arbeitsmappe " & ActiveWorkbook.name & _
"            " & vbCr & vbCr & _
" am " & Format(Now, "DD.MM.YYYY") & _
" um " & Format(Now, "HH:MM:SS") & vbCr & vbCr & _
" wurde von Benutzer " & Application.UserName & _
" geändert!", vbInformation, "  ÄNDERUNG"
End Sub

Vielen Dank im Voraus für Eure Unterstützung.
Mfg Eric

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
Änderung von Exceldateien protokollieren
16.06.2010 21:35:26
Exceldateien
Hallo Eric,
vielleicht genügt Dir schon folgende kleine Ergänzung :

Private Sub App_SheetChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)
protocol1 Application.UserName, Format(Now, "DD.MM.YYYY"), _
Format(Now, "HH:MM:SS"), Target.Address(, , , True), "Änderung"
MsgBox "Zelle " & Target.Address(False, False) & _
" aus Blatt " & ActiveSheet.Name & _
" aus Arbeitsmappe " & ActiveWorkbook.Name & _
"            " & vbCr & vbCr & _
" am " & Format(Now, "DD.MM.YYYY") & _
" um " & Format(Now, "HH:MM:SS") & vbCr & vbCr & _
" wurde von Benutzer " & Application.UserName & _
" geändert!", vbInformation, "  ÄNDERUNG"
End Sub
Gruß, NoNet
Anzeige
AW: Änderung von Exceldateien protokollieren
17.06.2010 18:51:07
Exceldateien
Hallo NoNet
vielen Dank für die Info, hab das wie folgt umgebaut :

'   Modul prot
Option Explicit
'   Variablen setzen
Public myApp As New cls_pro
Sub protocol()
Set myApp.App = Application
End Sub
Public Sub protocol1(BENUTZER As String, DATUM As String, _
UHRZEIT As String, DATEINAME As String, Modus As String)
Open "E:\_EIGENE\ZUGRIFFE.txt" For Append As #1
Print #1, BENUTZER & vbTab & DATUM & vbTab _
& UHRZEIT & vbTab & DATEINAME & vbTab & vbTab; Modus
Close #1
End Sub
Public Sub protocol2(BENUTZER As String, DATUM As String, _
UHRZEIT As String, DATEINAME As String, AENDERUNG As String, _
Modus As String)
Open "E:\_EIGENE\AENDERUNG.txt" For Append As #1
Print #1, BENUTZER & vbTab & DATUM & vbTab _
& UHRZEIT & vbTab & DATEINAME & vbTab; AENDERUNG & vbTab; Modus
Close #1
End Sub

und
' **********************************************************************
'   Klassenmodul cls_pro
Option Explicit
'   Variablen setzen
Public WithEvents App As Application
Private Sub App_WorkbookBeforeClose _
(ByVal Wb As Workbook, Cancel As Boolean)
protocol1 Application.UserName, Format(Now, "DD.MM.YYYY"), _
Format(Now, "HH:MM:SS"), Wb.FullName, "ENDE"
End Sub
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
protocol1 Application.UserName, Format(Now, "DD.MM.YYYY"), _
Format(Now, "HH:MM:SS"), Wb.FullName, "START"
End Sub
Private Sub App_SheetChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)
protocol2 Application.UserName, Format(Now, "DD.MM.YYYY"), _
Format(Now, "HH:MM:SS"), Target.Address(, , , True), _
Target.Value, "AENDERUNG"
'          MsgBox "Zelle " & Target.Address(False, False) & _
'          " aus Blatt " & ActiveSheet.name & _
'          " aus Arbeitsmappe " & ActiveWorkbook.name & _
'          "            " & vbCr & vbCr & _
'          " neuer Eintrag " & vbTab & Target.Value & _
'          "            " & vbCr & vbCr & _
'          " am " & Format(Now, "DD.MM.YYYY") & _
'          " um " & Format(Now, "HH:MM:SS") & vbCr & vbCr & _
'          " wurde von Benutzer " & Application.UserName & _
'          " geändert!", vbInformation, "  ÄNDERUNG"
End Sub

super, DANKE, das passt, nur bei der Markierung von mehreren Fehlern kommt "Fehlercode 13", nicht unbedingt störend, da in diesem Fall alle Daten über Userform eingegeben werden.
Ggf. gibt es auch dafür eine Lösung, danke für eine Unterstützung dazu im voraus.
Msgbox auskommentiert, da nur zu Testzwecken notwendig !
Vielen Dank für die Hilfe
MfG ERIC
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige