Avatar of upobDaPlaya
 asked on

Read Only Workbook - How to Log who reads the workbook

I have a Ready Only workbook that is available to 100 people.  I want to determine who uses the workbook.  However, I can not add code to the OnOpen event as since the Workbook is read only then my code can not write the users name to a cell.  My other concern is a macro may open this read only workbook and I do not want to impact any macros that may open this read only workbook and extract info..

Any suggestions on how I can figure out who uses the workbook without having to email all 100 individuals..
VBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Roy Cox

8/22/2022 - Mon
David Favor

Place your workbook behind a CMS which forces a login for access.

You'll know instantly.

Likely much easier to use a working CMS, like WordPress, than hand roll your own.

Whats a CMS...Whatever it is I think that solution would be problematic as if today am unaware that a macro opens this read only workbook and then out of nowhere I put up a CMS I assume the macro would fail ?
David Favor

CMS == WordPress, Drupal, Joomla, 100s of others.

If you're new to CMS software, stick with WordPress.

With a CMS, you'd just setup your workbook as restricted content, so a person has to login to use your workbook. Then just track user stats.

You can also go a step further + break apart your workbook into separate content pages, to gather more granular data.

Read up on WordPress. You'll likely be surprised by all the features a CMS can provide for you.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Roy Cox

Maybe write to a text file. Create a text file named log, change the path in the code to suit

Option Explicit

Private Sub Workbook_Open()
    Dim sPath As String
    sPath = ThisWorkbook.Path & Application.PathSeparator & "log.txt"    ''///Change to your folder
    Open sPath For Append As #1
    Write #1, Application.UserName & " , " & Format(Now, "yyyy/mm/dd hh:mm")
    Close #1
End Sub

Open in new window

Roy Cox

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Hi Roy, what is the purpose of the ihandle...
Roy Cox

The VBA FreeFile function reserves the next available file number for VBA file input/output. When you open a file for writing or reading in VBA, you must refer to that file with a unique integer file number. The FreeFile function determines this unique file number for you so you can use it to open, read, and write files using VBA. It avoids a conflict if your chosen number has been used.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

Thanks for the detail
Roy Cox

Pleased to help