Prevent Unauthorised Users Access Q

S

Sean

How Could I prevent users outside a set list access to opening a Word
Document?

The username would be that displayed within Tools-User Info.

If it is an "unauthorised User", then I would like a Dialog Box
appearing with an OK button, that states "Secret"?

Any guidance would be appreciated
 
S

Shauna Kelly

Hi Sean

In Word 2003, Tools > Protection. At the bottom of the task pane, click
Restrict Permission. Note that this only works if the machine has the
appropriate client installed, and that depends on having the appropriate
version of Windows Server. See
http://office.microsoft.com/en-us/help/HA010397891033.aspx for more details.

In earlier versions of Word, or in an environment other than one that can
use IRM, then a macro of the kind you describe will have no real effect.
There are many easy ways for a user to avoid your macro or its effects, and
popping up a message that says "Secret" will just encourage people to try.

You could put a password on the document that prevents anyone opening the
document unless they know the password, and that is quite secure. Tools >
Options > Security. Click the Advanced button to set the encryption type. If
you choose one of the serious encryption methods, remember the password,
because there is no reasonable way to get it back.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
S

Sean

Hi Sean

In Word 2003, Tools > Protection. At the bottom of the task pane, click
Restrict Permission. Note that this only works if the machine has the
appropriate client installed, and that depends on having the appropriate
version of Windows Server. Seehttp://office.microsoft.com/en-us/help/HA010397891033.aspxfor more details.

In earlier versions of Word, or in an environment other than one that can
use IRM, then a macro of the kind you describe will have no real effect.
There are many easy ways for a user to avoid your macro or its effects, and
popping up a message that says "Secret" will just encourage people to try.

You could put a password on the document that prevents anyone opening the
document unless they know the password, and that is quite secure. Tools >
Options > Security. Click the Advanced button to set the encryption type. If
you choose one of the serious encryption methods, remember the password,
because there is no reasonable way to get it back.

Hope this helps.

Shauna Kelly. Microsoft MVP.http://www.shaunakelly.com/word









- Show quoted text -

Thanks Shauna, I'm aware of the limitations but just want to create a
small hurles. I've successfully done it in Excel, but word is just a
different ball game for me and am unsure. This is my attempt

Private Sub Document_Open()
Dim myArray As Variant
Dim arName As String
With Application
If IsError(.Application.Match(.UserName, "Joe Bloggs", 0)) Then
MsgBox "You are NOT Permitted to access this File " & vbCr & _
"" & vbCr & _
"Please Contact Joe Bloggs at " & vbCr & _
"" & vbCr & _
"ABC Group +00123 1 123456789"
Application.DisplayAlerts = False
ThisDocument.Close False
Else
Next
End If
End With

End Sub
 
J

Jay Freedman

Sean said:
Thanks Shauna, I'm aware of the limitations but just want to create a
small hurles. I've successfully done it in Excel, but word is just a
different ball game for me and am unsure. This is my attempt

Private Sub Document_Open()
Dim myArray As Variant
Dim arName As String
With Application
If IsError(.Application.Match(.UserName, "Joe Bloggs", 0)) Then
MsgBox "You are NOT Permitted to access this File " & vbCr & _
"" & vbCr & _
"Please Contact Joe Bloggs at " & vbCr & _
"" & vbCr & _
"ABC Group +00123 1 123456789"
Application.DisplayAlerts = False
ThisDocument.Close False
Else
Next
End If
End With

End Sub

Hi Sean,

As Shauna said, nothing involving a macro is likely to be even a small
hurdle.

Try this experiment: set up the document with your macro. Close the
document. Now go to Tools > Macro > Security and set the level to High or
Very High (and note that High is the default setting, and many companies
force their employees to use Very High). Now open the document. What
happens?

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
S

Sean

Hi Sean,

As Shauna said, nothing involving a macro is likely to be even a small
hurdle.

Try this experiment: set up the document with your macro. Close the
document. Now go to Tools > Macro > Security and set the level to High or
Very High (and note that High is the default setting, and many companies
force their employees to use Very High). Now open the document. What
happens?

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.- Hide quoted text -

- Show quoted text -

Thanks Jay

Yes I'm aware what happens.

In Excel I action a "blank startup Sheet", that is the only sheet
visible (actioned initially on Worksheet_Close event), so thats what
opens up if the security is set to High, if its to low, my routine
runs, if to High, only a blank sheet appears. I just wanted to
replicate this in a Word Document, so my Start point was to allow only
certain users access based on Application. username
 
J

Jay Freedman

Thanks Jay

Yes I'm aware what happens.

In Excel I action a "blank startup Sheet", that is the only sheet
visible (actioned initially on Worksheet_Close event), so thats what
opens up if the security is set to High, if its to low, my routine
runs, if to High, only a blank sheet appears. I just wanted to
replicate this in a Word Document, so my Start point was to allow only
certain users access based on Application. username

OK, I can understand that.

From a programming point of view, your first attempt has some
problems.

- Word VBA doesn't have a Match function like Excel's. You could read
the authorized usernames into a delimited string, like "|Joe
Bloggs|Harry Doe|Jim Beam|", and use the InStr function to tell you
whether that string contains the substring "|" & Application.UserName
& "|". The function returns a positive integer if the substring is
there, or zero if not.

- You have a Next statement but no matching For statement. And you
don't need the Else statement because you don't do anything when the
If condition is false. The two Dim statements declare variables that
are never used, but you do need some way to get the list of authorized
names, and a variable to store it (probably Dim blahblah As String).

- Instead of ThisDocument.Close, use
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

- The .DisplayAlerts parameter may not be sufficient to suppress all
messages. You'll have to test under the expected conditions.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
S

Shauna Kelly

Hi Sean

And finally, bear in mind that users can, do and should be allowed to change
the information at Tools > Options > User Information.

A change may prevent authorized people from seeing the document, and allow
unauthorized people to see it.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

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

Top