ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   getting a list of users with permissions to a workbook (https://www.excelbanter.com/excel-programming/321942-getting-list-users-permissions-workbook.html)

Eric[_27_]

getting a list of users with permissions to a workbook
 
I have a workbook on a shared exchange folder, and I want to create a list
of all of those users in a new sheet.

Can I do this?

TIA



Claud Balls

getting a list of users with permissions to a workbook
 
Tough question, I did find these tools on the net. I'm not really sure
how excel can use them, but I'm trying to figure it out.
Download:
http://www.microsoft.com/ntserver/nt...25/default.asp

Directions: http://www.serverwatch.com/tutorials...le.php/1476741



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Claud Balls

getting a list of users with permissions to a workbook
 
I got this to work, but it took some tweaking. First make sure to
download the ADSI resource kit from the link I posted. Copy the script
and paste it into a file, save the file with a .vbs extension. I name
my file Check_Perms.vbs.

Paste the following at the bottom of the .vbs file, and make sure to
correct lines that have been cut off.

Sub WriteToLog(Message, sTarget) ' Creating and writing to a text file
Dim fLog, Fso
Set Fso = CreateObject("Scripting.FileSystemObject")
' Create the log file if it does not exist
If not Fso.FileExists(sTarget & ".txt") Then
Set fLog = Fso.CreateTextFile(sTarget & ".txt", True)
fLog.Close
End If
' Append to the log file
Set fLog = Fso.OpenTextFile(sTarget & ".txt", 8)
fLog.WriteLine(Message)
fLog.Close
End Sub

Then replace the wscript.echo commands with a command calling the sub I
just gave you. Example:
WriteToLog sMsg & "ADS_ACEFLAG_UNKNOWN", sTarget

Now in your Excel sheet use:
Private Sub Workbook_Open()
Dim strTextFilePath As String
strTextFilePath = ActiveWorkbook.FullName & ".txt"
'Creates temporary permissions text file
'Correct the .vbs path name in the shell command
Shell ("cscript //nologo H:\Excel\WritePerms.vbs ACTION=SHOW
TARGET=" & ActiveWorkbook.FullName)

While Dir(strTextFilePath) = ""
'Waits for file to be created
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Wend

'Imports permissions text file
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & strTextFilePath, Destination:=Range("A1"))
.SaveData = True
.AdjustColumnWidth = True
.TextFilePlatform = xlWindows
.TextFileStartRow = 2
.TextFileParseType = xlFixedWidth
.TextFileColumnDataTypes = Array(1, 1)
.TextFileFixedColumnWidths = Array(20)
.Refresh BackgroundQuery:=False
End With

'Deletes temporary file
Kill strTextFilePath
End Sub

Let me know if it works for you.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 09:03 AM.

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