ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to restrict access (https://www.excelbanter.com/excel-programming/422849-macro-restrict-access.html)

santaviga

macro to restrict access
 
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

CFS

macro to restrict access
 
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


Terielad

macro to restrict access
 
Excellant Thanks.



"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


Terielad

macro to restrict access
 
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


CFS

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


Terielad

macro to restrict access
 
Great Thanks.



"CFS" wrote:

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


Gord Dibben

macro to restrict access
 
What if the file is not being edited at this time?


Gord Dibben MS Excel MVP

On Thu, 22 Jan 2009 11:19:02 -0800, Terielad
wrote:

Excellant Thanks.



"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




All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com