View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
jetted[_5_] jetted[_5_] is offline
external usenet poster
 
Posts: 1
Default Log when cells are copied


Hi Sharon

I would use these 3 macro


Sub auto_open()
'grab the user name
Dim LogFile As String
Dim EnvString As String
Dim Indx As Long
Dim regRoot As Long

Indx = 1
Do
EnvString = Environ(Indx)
If LCase(Left(EnvString, 9)) = "username=" Then 'Lan user id
regUserID = Right(EnvString, Len(EnvString) - 9)
End If
Indx = Indx + 1
Loop Until EnvString = ""
Indx = 0

LogFile = "c:\activite.log" ' this must be a common directory
ChDir "c:\"
donnees = Now()
Open LogFile For Append Shared As #1
Print #1, "Excel was openned at: " & donnees & " by " &
regUserID
Close #1
end sub

Sub AUTO_CLOSE()
'close the file
Dim LogFile As String
Dim EnvString As String
Dim Indx As Long
Dim regRoot As Long

'Dim applicationClass As New AppEventClass
'Set applicationClass.appl = Application


Indx = 1
Do
EnvString = Environ(Indx)
If LCase(Left(EnvString, 9)) = "username=" Then 'Lan user id
regUserID = Right(EnvString, Len(EnvString) - 9)
End If
Indx = Indx + 1
Loop Until EnvString = ""
Indx = 0


LogFile = "c:\activite.log"
ChDir "c:\"
donnees = Now()
Open LogFile For Append Shared As #1 'pointeur adresse,
logfile=#1
Print #1, "Closed excel at " & donnees & " by " & regUserID
Print #1, "----------------------------------"
Close #1
Worksheets("Sheet1").Select
ActiveWorkbook.Save
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
'as soon there is a change this is log
nom = ActiveSheet.Name

refere = Target.Address
LogFile = "c:\activite.log"
ChDir "c:\"
donnees = Now()
oldvalue = ActiveCell.Value
MsgBox oldvalue
Open LogFile For Append Shared As #1
Print #1, "Changes made in workbook: " & nom & " in cell: " &
refere & " new input: " & Target & " " & donnees
Close #1
'MsgBox Target
'MsgBox refere
End Sub


--
jetted
------------------------------------------------------------------------
jetted's Profile: http://www.excelforum.com/member.php...o&userid=17532
View this thread: http://www.excelforum.com/showthread...hreadid=558517