View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
bpeltzer bpeltzer is offline
external usenet poster
 
Posts: 180
Default No changes during Read-Only mode

Before setting the user and time, check the status:
if thisworkbook.readonly = false then
....
end if

"Jasmine" wrote:

The following code runs on a spreadsheet that lots of people access when the
workbook opens. My intention was to be able to see who had the workbook open
for long periods of time. However, what happens when you try to open it and
someone else already has it open, You get the Read Only choice and when you
click that to open, it still puts your UserName. Anyway to do this where it
doesn't update during Read Only mode? Thanks for the help!

Sub Workbook_Open()
ActiveSheet.Unprotect Password:="scbtloan"
Range("B1").Value = Environ("UserName")
Range("C1").Value = Format(Now, "dd mmm yyyy hh:mm:ss")
ActiveSheet.Protect Password:="scbtloan"
End Sub