Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DAS DAS is offline
external usenet poster
 
Posts: 26
Default Protection using Username

I have a workbook that has 10 different sheets with names ranging from
"Finance" to "Operations." What I would like to do is have the application
review the username upon opening and then run it against a list to first see
if that username is on the list. If it isn't, then nothing will open.
Secondly if it is on the list, I would like it to compare accesses to the
sheets, i.e.:

dsmith works in Operations
brogers works in Finance
mwilson works in both Operations and Finance

Dsmith should be able to view the "operations" sheet and nothing more, just
as brogers should view "finance" and nothing more. However, mwilson should
be able to view both the "operations" and "finance" sheets, but none of the
other 8 remaining sheets.

I am not sure where to even begin.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Protection using Username

If the user disabled macros when they opened the workbook, then they will
have the ability to access any sheet they want. So if you allow them to
open the workbook, then assume they will be able to access anything in the
workbook.

--
Regards,
Tom Ogilvy



"DaS" wrote:

I have a workbook that has 10 different sheets with names ranging from
"Finance" to "Operations." What I would like to do is have the application
review the username upon opening and then run it against a list to first see
if that username is on the list. If it isn't, then nothing will open.
Secondly if it is on the list, I would like it to compare accesses to the
sheets, i.e.:

dsmith works in Operations
brogers works in Finance
mwilson works in both Operations and Finance

Dsmith should be able to view the "operations" sheet and nothing more, just
as brogers should view "finance" and nothing more. However, mwilson should
be able to view both the "operations" and "finance" sheets, but none of the
other 8 remaining sheets.

I am not sure where to even begin.

  #3   Report Post  
Posted to microsoft.public.excel.programming
DAS DAS is offline
external usenet poster
 
Posts: 26
Default Protection using Username

The way the workbook is setup is that all sheets are initially hidden, so if
macros are disabled it opens to what looks like a blank sheet. Macros
enabled makes the screens visible as you click through the userform that only
pops up when they are enabled. Most of my end users have no idea how to
navigate through excel in the slightest bit, so I'm not too worried about
that one in a very few that knows the tricks. Does that make sense Tom?

"Tom Ogilvy" wrote:

If the user disabled macros when they opened the workbook, then they will
have the ability to access any sheet they want. So if you allow them to
open the workbook, then assume they will be able to access anything in the
workbook.

--
Regards,
Tom Ogilvy



"DaS" wrote:

I have a workbook that has 10 different sheets with names ranging from
"Finance" to "Operations." What I would like to do is have the application
review the username upon opening and then run it against a list to first see
if that username is on the list. If it isn't, then nothing will open.
Secondly if it is on the list, I would like it to compare accesses to the
sheets, i.e.:

dsmith works in Operations
brogers works in Finance
mwilson works in both Operations and Finance

Dsmith should be able to view the "operations" sheet and nothing more, just
as brogers should view "finance" and nothing more. However, mwilson should
be able to view both the "operations" and "finance" sheets, but none of the
other 8 remaining sheets.

I am not sure where to even begin.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Protection using Username

several approaches:

First two are demo'd from the immediate window:
sstr = environ("Username")
? sStr
OgilvyTW

sstr = environ("Computername")
? sStr
OLGILTG4

---------------------------------------

http://vbnet.mvps.org/index.html?cod...sergetinfo.htm

---------------------------------------

Michel Pierron - Gets the Fullname
Sub GetFullName()
Dim Domain$, User$
With CreateObject("Wscript.Network")
Domain = .UserDomain: User = .UserName
End With
MsgBox GetObject("WinNT://" & Domain & "/" & User & ",user").FullName, 64
End Sub

----------------------------------

From Google Search:
http://groups.google.com/advanced_group_search
=========
From: Trevor Shuttleworth )
Subject: Code to show login name
Newsgroups: microsoft.public.excel.programming
Date: 2001-01-16 12:54:01 PST




Private Declare Function apiGetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nsize As Long) As Long

Sub GetUserNameTest()
MsgBox fOSUserName
End Sub

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX < 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function

Regards

Trevor

then it is a matter of looping through the list of usernames and unhiding
the appropriate sheets when the username is found.
--
Regards,
Tom Ogilvy




"DaS" wrote:

The way the workbook is setup is that all sheets are initially hidden, so if
macros are disabled it opens to what looks like a blank sheet. Macros
enabled makes the screens visible as you click through the userform that only
pops up when they are enabled. Most of my end users have no idea how to
navigate through excel in the slightest bit, so I'm not too worried about
that one in a very few that knows the tricks. Does that make sense Tom?

"Tom Ogilvy" wrote:

If the user disabled macros when they opened the workbook, then they will
have the ability to access any sheet they want. So if you allow them to
open the workbook, then assume they will be able to access anything in the
workbook.

--
Regards,
Tom Ogilvy



"DaS" wrote:

I have a workbook that has 10 different sheets with names ranging from
"Finance" to "Operations." What I would like to do is have the application
review the username upon opening and then run it against a list to first see
if that username is on the list. If it isn't, then nothing will open.
Secondly if it is on the list, I would like it to compare accesses to the
sheets, i.e.:

dsmith works in Operations
brogers works in Finance
mwilson works in both Operations and Finance

Dsmith should be able to view the "operations" sheet and nothing more, just
as brogers should view "finance" and nothing more. However, mwilson should
be able to view both the "operations" and "finance" sheets, but none of the
other 8 remaining sheets.

I am not sure where to even begin.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Data Protection Best Practice: AKA: Real Sheet Protection Mushman(Woof!)[_2_] Excel Discussion (Misc queries) 4 December 30th 09 01:20 AM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
username robzrob Excel Worksheet Functions 2 May 4th 08 05:59 PM
Username Log PaulJ Excel Discussion (Misc queries) 8 March 1st 06 11:51 AM
Username Lawlera[_2_] Excel Programming 3 December 23rd 03 09:21 AM


All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"