Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I limit use to only local network?

Status
Not open for further replies.

bsurfn99

Technical User
Mar 23, 2005
34
US
I would like to limit the use of file to only a local network. Anybody have an idea how I could accomplish this? I was thinking of inserting a statement in my AutoOpen macro to look for a specific network drive. If the drive was present it would open, if not present it would close. Unfortunately I don't know how to approach this problem.

Any Ideas?

Thanks,
BsurfN99
 
Would it not be better, and simpler, to use Permissions?

You can do it with a document open event, and checking for a specific drive, as you thought.

BTW: is this for Word? You don't say. If it is, you may want to use the Document_Open event. Also, for the code below, you need a reference to Microsoft Scrtipting Runtime.

Code:
Private Sub Document_Open()
Dim fso As Scripting.FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.DriveExists("H:\") = False Then
   MsgBox "HEY!!!!  Whaddya doing???"
   ActiveDocument.Close
End If
End Sub
If there is no H drive, the file can not be opened. Well technically, it DOES open, but immediately closes.

You can also use .FolderExists
Code:
If fso.FolderExists("U:\Yadda\BaddaBing") = False Then


or even a file.
Code:
If fso.FileExists("X:\Whatever\ho_hum.txt") = False Then

faq219-2884

Gerry
My paintings and sculpture
 
bsurfn99,
Keep in mind that any code you put in an Office document will be subject to Macro Security which may prevent your macro from running.

Permissions would be the way to go.

Hope this helps,
CMP


[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thanks Fumei! That was exactly what I was thinking of.

As far as Permissions vs. macros. I'm not familiar with how to assign permissions to an individual file in windows. I'm trying to prevent unauthorized use offsite.

Could I assign Permissions in a way that would address my concerns?

BTW: I'm working in excel.


Thanks again for the help.

BsurfN99
 
I forgot to ask about your comment on "you need a reference to "Microsoft Scrtipting Runtime."

What do I need to do to for this?

BsurfN99
 
The file itself (or its template) MUST have a reference to Microsoft Scripting Runtime. You add it using (in the VBE) Tools > References.
Could I assign Permissions in a way that would address my concerns?
Yes, if you have admin rights and access to Permissions.


I would suggest you talk this over with whoever handles your network. CMP is quite correct in that Macro Security may affect how things work. Also, let's face it, any Word VBA solution is not (and likely never will be) a fully secure anything.

If you have serious concerns about access from outside, then that should really be handled as a network security issue, not a file access issue. My document open code will work for Joe Blo trying to open the file, but a seriously knowledgeable nasty person could blow by it in a flash.

Permission/policy level security is not faultless either, but it sure is a heck of a lot more secure than a VBA solution.

The question is, what is your threat level? What are the consequences? How important IS this?

At the Permissions level, the admin would simply explicitly list members of the local network as having access to that file/folder. Everyone else, no access. Done. Essentially it is really a kind of reverse access. NO ONE has access, with these Exceptions (the members of the local network).


faq219-2884

Gerry
My paintings and sculpture
 
Gerry Thanks,

It works like a charm. As for permissions vs. VB, I realize that VB is limited security, the file is a low consequence, so I think the VB solution is fine. I understand that permissions would be the ideal solution, but I don't have admin access.

Thanks again for your help.

BsurfN99
 

bsurfn99,

I notice that over the past 2 years, you have posted several threads and have received many good tips related to your stated needs. Yet, you have NEVER responded, to
[blue]
Thank Tek-Tip Contributor
for this valuable post!
[/blue].

The Stars accomplish several important things.

First, it gives positive feedback to contributors, that their posts have been helpful.

Second, it identifies threads as containing helpful posts, so that other members can benefit.

And third, it identifies the original poster (OP), as a grateful member that not only receives, but also is willing to give tokens of thanks.

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top