Alt + F11 to open VBE
CTRL + r to open Project Explorer.
Select your workbook/project and expand it.
Expand Microsoft Excel Objects.
Double-click on Thisworkbook module.
Paste this into that module.
Private Sub Workbook_Open()
Dim sFile As String
Dim sText
Dim ff As Long
sFile = Application.DefaultFilePath
' or maybe
'sFile = ThisWorkbook.Path
If Right$(sFile, 1) <> "\" Then sFile = sFile & "\"
sFile = sFile & "logTest.txt"
sText = Environ("Username") & vbTab & Format(Now, "yyyy-mm-dd hh:mm:ss")
'Environ("Username") is the login name of user opening the workbook
ff = FreeFile
Open sFile For Append As #ff
Print #ff, sText
Close #ff
End Sub
Save and close the workbook.
Gord Dibben MS Excel MVP