Hey everyone, first post here.
I have a file that multiple users access on a shared network drive (sharepoint).
I have this macro setup to update a .log file with the username and date/time when users open the file. Here's the logmessage code:
Sub LogInfo(LogMessage As String)
'set path and name of the log file where you want to save
'the log file
Dim path As String
path = ThisWorkbook.path
Const LogFileName As String = "\Log\logfile.LOG"
Dim FileNum As Integer
Dim fullFilePath As String
fullFilePath = path & LogFileName
FileNum = FreeFile ' next file number
Open fullFilePath For Append As #FileNum ' creates the file if it doesn't exist
Write #FileNum, LogMessage ' write information at the end of the text file
Close #FileNum ' close the file
Exit Sub
Here is the call in the Sub Workbook_Open():Application.AskToUpdateLinks = False
LogInfo ThisWorkbook.Name & " opened by " & _
Application.userName & " " & Format(DateTime.Now, "yyyy-mm-dd hh:nn AM/PM")
This works correctly for me, and only me. Otherwise it errors out. Any suggestions? The location of the workbook and the log file is on a shared network drive that all users have access to.
Appreciate any feedback you can give!
I have a file that multiple users access on a shared network drive (sharepoint).
I have this macro setup to update a .log file with the username and date/time when users open the file. Here's the logmessage code:
Sub LogInfo(LogMessage As String)
'set path and name of the log file where you want to save
'the log file
Dim path As String
path = ThisWorkbook.path
Const LogFileName As String = "\Log\logfile.LOG"
Dim FileNum As Integer
Dim fullFilePath As String
fullFilePath = path & LogFileName
FileNum = FreeFile ' next file number
Open fullFilePath For Append As #FileNum ' creates the file if it doesn't exist
Write #FileNum, LogMessage ' write information at the end of the text file
Close #FileNum ' close the file
Exit Sub
Here is the call in the Sub Workbook_Open():Application.AskToUpdateLinks = False
LogInfo ThisWorkbook.Name & " opened by " & _
Application.userName & " " & Format(DateTime.Now, "yyyy-mm-dd hh:nn AM/PM")
This works correctly for me, and only me. Otherwise it errors out. Any suggestions? The location of the workbook and the log file is on a shared network drive that all users have access to.
Appreciate any feedback you can give!