ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating an access log (https://www.excelbanter.com/excel-programming/357568-creating-access-log.html)

matpj[_57_]

Creating an access log
 

Is it at all possible to create a text file, so that when any user opens
a particular spreadsheet, their username and current system date is
appended to the text file?

I'm inerested in creating an access log for one of our spreadsheets.
I'm no VBA expert, but i'm assuming this might quite straight forward.
Havent got a clue how to get the user's login ID, or Excel User name,
so any help will be appreciated.

thanks in advance,
Matt


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=528071


K Dales[_2_]

Creating an access log
 
Yes, I answered the same question a while back but cannot remember the link;
search this group for access log
--
- K Dales


"matpj" wrote:


Is it at all possible to create a text file, so that when any user opens
a particular spreadsheet, their username and current system date is
appended to the text file?

I'm inerested in creating an access log for one of our spreadsheets.
I'm no VBA expert, but i'm assuming this might quite straight forward.
Havent got a clue how to get the user's login ID, or Excel User name,
so any help will be appreciated.

thanks in advance,
Matt


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=528071



matpj[_59_]

Creating an access log
 

hi,

thanks for the response.
I couldn't find a post with a reply frmo you, but I found another on
that does exactly what I want, although the spreadsheet I am creatin
will be saved in a Notes database.

I need the log file to be in a specified network path although when
try to use that, it throws up an error.

the original code for the log is:


Code
-------------------
Sub DoTheLog(myKey As String)
Open ThisWorkbook.Path & "\" & Left(ActiveWorkbook.Name, _
Len(ActiveWorkbook.Name) - 4) & "_usage.log" For Append As #1
Print #1, myKey & vbTab & Application.UserName _
& vbTab & fOSUserName _
& vbTab & fOSMachineName _
& vbTab & Format(Now, "mmmm dd, yyyy hh:mm:ss")
Close #1
End Su
-------------------


i'm trying to change the Open bit to read:


Code
-------------------
Open "\\Cs_fs1\Prodvol\Techserv\" & Left(ActiveWorkbook.Name, _
Len(ActiveWorkbook.Name) - 4) & "_usage.log" For Append As #1

-------------------


but when I do this it displays an error saying cannot find path.
That is a valid path and it is currently mapped to my PC

--
matp
-----------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=52807


NickHK

Creating an access log
 
matpj,
What does the "Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4)"
part evaluate to ?

NickHK

"matpj" wrote in
message ...

hi,

thanks for the response.
I couldn't find a post with a reply frmo you, but I found another one
that does exactly what I want, although the spreadsheet I am creating
will be saved in a Notes database.

I need the log file to be in a specified network path although when I
try to use that, it throws up an error.

the original code for the log is:


Code:
--------------------
Sub DoTheLog(myKey As String)
Open ThisWorkbook.Path & "\" & Left(ActiveWorkbook.Name, _
Len(ActiveWorkbook.Name) - 4) & "_usage.log" For Append As #1
Print #1, myKey & vbTab & Application.UserName _
& vbTab & fOSUserName _
& vbTab & fOSMachineName _
& vbTab & Format(Now, "mmmm dd, yyyy hh:mm:ss")
Close #1
End Sub
--------------------


i'm trying to change the Open bit to read:


Code:
--------------------
Open "\\Cs_fs1\Prodvol\Techserv\" & Left(ActiveWorkbook.Name, _
Len(ActiveWorkbook.Name) - 4) & "_usage.log" For Append As #1

--------------------


but when I do this it displays an error saying cannot find path.
That is a valid path and it is currently mapped to my PC.


--
matpj
------------------------------------------------------------------------
matpj's Profile:

http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=528071




matpj[_60_]

Creating an access log
 

that makes sure that the ".xls" is removed from the file name when
giving a name to the log file! :)


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=528071



All times are GMT +1. The time now is 12:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com