![]() |
No changes during Read-Only mode
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 |
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 |
No changes during Read-Only mode
Thank you so much! That worked great!
"bpeltzer" wrote: 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 |
All times are GMT +1. The time now is 11:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com