View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
CFS CFS is offline
external usenet poster
 
Posts: 12
Default macro to restrict access

Try this:

Private Sub Workbook_Open()
Dim adminpass As String
adminpass = InputBox("Enter admin password:")
If adminpass < "1234" Then
MsgBox "This file is being edited you cannot access this at this time"
ThisWorkbook.Close False
Else
ThisWorkbook.Activate
End If
End Sub
--
CFS


"Terielad" wrote:

Just noticed that this works but how do I the administrator get access again
to remove the macro

Regards

"CFS" wrote:

Use a Workbook event:

Private Sub Workbook_Open()
MsgBox "This file is being edited you cannot access this at this time"
ThisWorkbook.Close False
End Sub

--
CFS


"santaviga" wrote:

Hi,

I am looking for a macro to run in an excel file so that when you open the
file it pops up with a message, this file is being edited you cannot access
this at this time and when you press ok the excel file will close.

Can any one give me some help on this.

Regards