Disable macros if taken off of network

eggtimer

Board Regular
Joined
Apr 16, 2003
Messages
125
Hi

I have a worksheet that is heavily locked down. For agents to use it they access a form that unlocks the sheet, unhides requested rows & ranges then locks it back up, this form is used by about 80 users

My problem now is that I have a second set of sections that can only be access by one user and this user is not able to access the original sections, so I have created a second form that opens just what they require

And below I have the code that prevents Jo Blogg’s accessing the form 1 (in addition to Jo Bloggs on form2 two people can access both)
Code:
Sub showForm1()
Select Case Application.UserName
Case Is = "Jo Bloggs"
MsgBox "Selection failed", vbOK
Case Else
FORM1.Show
End Select
End Sub

Code:
Sub ShowForm2()
Select Case Application.UserName
Case Is = "John Smith", "Jo Bloggs", "Bill Brown" 
Form2.Show
Case Else
MsgBox "Selection failed", vbOK
End Select
End Sub

My worry is that if a copy of the form is taken off of our company network (the master is read only and loads of copies are saved each day) then because they will not be recognised as Jo Bloggs they will have access to open the section they are restricted from

Is there any sort of code I can write to disable all macros (or prevent this form from being opened) if it is taken off of the company network?

Any help appreciated

Cheers

Wayne
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You could add a block of code to the very beginning of your VBA code (or Workbook_Open) event that checks the path that the file is stored in, and if it is not located in the pre-determined company path, it boots them out of the file, i.e.
Code:
'   Get path that this macro file is currently stored in
    Dim FilePath As String
    FilePath = ActiveWorkbook.Path
    
    If FilePath <> "D:\CompanyDir\SomeDirectory" Then
        MsgBox "File is not on company network", vbOKOnly, "ERROR!"
        Application.Quit
    Else
        MsgBox "File is on company network", vbOKOnly, "OK to Proceed"
    End If
 
Upvote 0
Solution

Forum statistics

Threads
1,206,833
Messages
6,075,130
Members
446,123
Latest member
junkyardforme

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top