macro to restrict access

  • Thread starter Thread starter santaviga
  • Start date Start date
S

santaviga

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
 
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
 
Excellant Thanks.



CFS said:
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
 
Just noticed that this works but how do I the administrator get access again
to remove the macro

Regards
 
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
 
Great Thanks.



CFS said:
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
 
What if the file is not being edited at this time?


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top