Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PJ PJ is offline
external usenet poster
 
Posts: 112
Default File owner attributes through Excel VBA

Is it possible to use VBA to determine the owner of a file saved on a network
share? I am trying to get the ID of the person logged in when the file was
created on the server. The file itself is not an MS office file however, I'm
just trying to get the name of the owner as part of my macro in Excel.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default File owner attributes through Excel VBA

If you can get the ownership through any tool then you should be able to get
the ownship through VBA since VBA can call any application. The only way I
know of to get a file permission on a server is to be able to map a drive to
the server or login into the server. If you don't have permission to do
either of these operations then you won't be able to get the ownship through
VBA.

I you tell me how you get the ownship of the file without using VBA then I
can write code in VBA to do the same operation. VBA can call any DLL and
network login and transversing the file system to get the owner is possible
through a Win32 Dll.

"PJ" wrote:

Is it possible to use VBA to determine the owner of a file saved on a network
share? I am trying to get the ID of the person logged in when the file was
created on the server. The file itself is not an MS office file however, I'm
just trying to get the name of the owner as part of my macro in Excel.

  #3   Report Post  
Posted to microsoft.public.excel.programming
PJ PJ is offline
external usenet poster
 
Posts: 112
Default File owner attributes through Excel VBA

Hi Joel,

I work in an all Windows environment and have read/write access to the
folder where the particular files are stored. I usually right-click on the
file from Windows Explorer, choose Properties, click the Advanced button on
the Security tab, and finally switch to the Owner tab which shows me the
current owner. If there is any way to return the owner's name using VBA that
would be great.

PJ

"Joel" wrote:

If you can get the ownership through any tool then you should be able to get
the ownship through VBA since VBA can call any application. The only way I
know of to get a file permission on a server is to be able to map a drive to
the server or login into the server. If you don't have permission to do
either of these operations then you won't be able to get the ownship through
VBA.

I you tell me how you get the ownship of the file without using VBA then I
can write code in VBA to do the same operation. VBA can call any DLL and
network login and transversing the file system to get the owner is possible
through a Win32 Dll.

"PJ" wrote:

Is it possible to use VBA to determine the owner of a file saved on a network
share? I am trying to get the ID of the person logged in when the file was
created on the server. The file itself is not an MS office file however, I'm
just trying to get the name of the owner as part of my macro in Excel.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default File owner attributes through Excel VBA

I found an easier way of getting the file owner without having to use a DLL.
Try this code

Sub owner()
Dim Folder As String
Dim FName As String

Folder = "c:\temp\"
RowCount = 1
FName = Dir(Folder & "*.*")

Do While FName < ""
Range("A" & RowCount) = Folder & FName
Range("B" & RowCount) = GetFileOwner(Folder, FName)

RowCount = RowCount + 1
FName = Dir()
Loop



End Sub

Function GetFileOwner(fileDir As String, fileName As String) As String

'On Error Resume Next
Dim secUtil As Object
Dim secDesc As Object
Set secUtil = CreateObject("ADsSecurityUtility")
Set secDesc = secUtil.GetSecurityDescriptor(fileDir & fileName, 1, 1)
GetFileOwner = secDesc.owner
End Function



"PJ" wrote:

Hi Joel,

I work in an all Windows environment and have read/write access to the
folder where the particular files are stored. I usually right-click on the
file from Windows Explorer, choose Properties, click the Advanced button on
the Security tab, and finally switch to the Owner tab which shows me the
current owner. If there is any way to return the owner's name using VBA that
would be great.

PJ

"Joel" wrote:

If you can get the ownership through any tool then you should be able to get
the ownship through VBA since VBA can call any application. The only way I
know of to get a file permission on a server is to be able to map a drive to
the server or login into the server. If you don't have permission to do
either of these operations then you won't be able to get the ownship through
VBA.

I you tell me how you get the ownship of the file without using VBA then I
can write code in VBA to do the same operation. VBA can call any DLL and
network login and transversing the file system to get the owner is possible
through a Win32 Dll.

"PJ" wrote:

Is it possible to use VBA to determine the owner of a file saved on a network
share? I am trying to get the ID of the person logged in when the file was
created on the server. The file itself is not an MS office file however, I'm
just trying to get the name of the owner as part of my macro in Excel.

  #5   Report Post  
Posted to microsoft.public.excel.programming
PJ PJ is offline
external usenet poster
 
Posts: 112
Default File owner attributes through Excel VBA

Joel,

That works like a charm. For my needs, I'm actually looking for a specific
file so I hard coded the name and set it to prompt the user running the macro
with the name of the person associated with creating the file. The file is a
temp file created by a 3rd party program so they need to track the person
down and have them exit the application before they can run the Excel macro
in it's entirety.

Thanks for the help!
PJ


"Joel" wrote:

I found an easier way of getting the file owner without having to use a DLL.
Try this code

Sub owner()
Dim Folder As String
Dim FName As String

Folder = "c:\temp\"
RowCount = 1
FName = Dir(Folder & "*.*")

Do While FName < ""
Range("A" & RowCount) = Folder & FName
Range("B" & RowCount) = GetFileOwner(Folder, FName)

RowCount = RowCount + 1
FName = Dir()
Loop



End Sub

Function GetFileOwner(fileDir As String, fileName As String) As String

'On Error Resume Next
Dim secUtil As Object
Dim secDesc As Object
Set secUtil = CreateObject("ADsSecurityUtility")
Set secDesc = secUtil.GetSecurityDescriptor(fileDir & fileName, 1, 1)
GetFileOwner = secDesc.owner
End Function



"PJ" wrote:

Hi Joel,

I work in an all Windows environment and have read/write access to the
folder where the particular files are stored. I usually right-click on the
file from Windows Explorer, choose Properties, click the Advanced button on
the Security tab, and finally switch to the Owner tab which shows me the
current owner. If there is any way to return the owner's name using VBA that
would be great.

PJ

"Joel" wrote:

If you can get the ownership through any tool then you should be able to get
the ownship through VBA since VBA can call any application. The only way I
know of to get a file permission on a server is to be able to map a drive to
the server or login into the server. If you don't have permission to do
either of these operations then you won't be able to get the ownship through
VBA.

I you tell me how you get the ownship of the file without using VBA then I
can write code in VBA to do the same operation. VBA can call any DLL and
network login and transversing the file system to get the owner is possible
through a Win32 Dll.

"PJ" wrote:

Is it possible to use VBA to determine the owner of a file saved on a network
share? I am trying to get the ID of the person logged in when the file was
created on the server. The file itself is not an MS office file however, I'm
just trying to get the name of the owner as part of my macro in Excel.

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
Edit VBA to print Directory including file owner into Excel Spread Melody Excel Programming 8 October 6th 08 02:23 PM
file owner properties Funtime Excel Programming 3 September 26th 08 04:24 PM
how can I check the current owner of the file stored in a common D INRIDisciples Excel Discussion (Misc queries) 0 November 28th 07 02:07 PM
Checking File Attributes of Excel CSV over Inter/Intra Net UBER_GEEK Excel Programming 2 June 7th 05 08:50 PM
owner/author of a file Dennis Hancy Excel Programming 6 November 2nd 04 06:51 AM


All times are GMT +1. The time now is 09:18 PM.

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

About Us

"It's about Microsoft Excel"