Saberexcel - o site de quem precisa aprender Macros Microsoft Excel VBA
Essa função do Aplicativo Microsoft Excel VBA(Visual Basic Application), registra o login do usuário, um bom procedimento para usar no desenvolvimento de um sistema acesso_log macros e funções para montar um sistema de logon
Saberexcel - dicas de macros microsoft excel vba
Option Explicit
Public Function LogInformation(LogMessage$)
On Error GoTo MakeFolder
Entry:
Open "c:\MyLogFiles\" & Left(ThisWorkbook.Name, _
Len(ThisWorkbook.Name) - 4) & _
" Log.Log" For Append As #1
Print #1, LogMessage
Close #1
Exit Function
MakeFolder:
MkDir "c:\MyLogFiles"
Resume Entry
End Function
'............................'
MODULO WKB
Option Explicit
Private Sub Workbook_Open()
LogInformation "Aberto" & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
'............................'
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
LogInformation ActiveSheet.Name & Selection.Address & " Changed: " & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
'............................'
Private Sub Workbook_BeforePrint(Cancel As Boolean)
LogInformation ActiveSheet.Name & "Printed: " & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
'............................'
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
LogInformation "Salvo em: " & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
LogInformation "Fechado em:" & Application.UserName & _
" " & Format(Now, "dd mmm yyyy hh:mm:ss")
End Sub
'..............................
'