Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Actually an easy one but I can't find anything on google. How can I check the access right to a folder (I just want to know if the user of the macro has access to a shared folder)? Is there any function that does that? (that would be on a network drive) thanks in advance Charles |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The manual check is to open the workbook, then ToolsSharedWorkbook and check
the list of users in Who has it open window. "Charles" wrote: Hi Actually an easy one but I can't find anything on google. How can I check the access right to a folder (I just want to know if the user of the macro has access to a shared folder)? Is there any function that does that? (that would be on a network drive) thanks in advance Charles |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, I meant a windows shared drive folder. Is there any way to do
something like hasaccesstofolder("C:\Folderx\") which would tell me if the user running the macro has access to the folder Charles |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have never used it, but check the UserStatus Property in VBA help. It
looks close to what you are describing. "Charles" wrote: Sorry, I meant a windows shared drive folder. Is there any way to do something like hasaccesstofolder("C:\Folderx\") which would tell me if the user running the macro has access to the folder Charles |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've never had occasion to use them, but there are objects designed for
network administrators; seems to me one of those would tell you what you needed to know. Of course, this would be a lot more useful if I could actually point to a URL documenting one of them, and my screen is kinda full up; I'm not sure where to look. But if you email me later, I'm sure I can find at least the general area I saw it in before. Something around MS' scripting documentation. --- "Charles" wrote: Actually an easy one but I can't find anything on google. How can I check the access right to a folder (I just want to know if the user of the macro has access to a shared folder)? Is there any function that does that? (that would be on a network drive) |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Have you tried
Dir("\\somedrive\somefolder") ? Tim "Charles" wrote in message ... Hi Actually an easy one but I can't find anything on google. How can I check the access right to a folder (I just want to know if the user of the macro has access to a shared folder)? Is there any function that does that? (that would be on a network drive) thanks in advance Charles |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Bob Bridges" wrote:
I've never had occasion to use them, but there are objects designed for network administrators; seems to me one of those would tell you what you needed to know. Of course, this would be a lot more useful if I could actually point to a URL documenting one of them, and my screen is kinda full up; I'm not sure where to look. But if you email me later, I'm sure I can find at least the general area I saw it in before. Something around MS' scripting documentation. --- "Charles" wrote: Actually an easy one but I can't find anything on google. How can I check the access right to a folder (I just want to know if the user of the macro has access to a shared folder)? Is there any function that does that? (that would be on a network drive) There is a sample he http://www.microsoft.com/technet/scr.../sedcvb02.mspx -- urkec |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Depending on what you're testing, why not just create a text file and try
saving/deleting/renaming... the file. If it fails on one of them, then they don't have that kind of access. Charles wrote: Hi Actually an easy one but I can't find anything on google. How can I check the access right to a folder (I just want to know if the user of the macro has access to a shared folder)? Is there any function that does that? (that would be on a network drive) thanks in advance Charles -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dave
That's what I was thinking to initially. But I am a bit concerned about having a dozen of users doing it all the time and the potential pollution if the macro fails and files keep accumulating. Ideally it would be a function that does something like reading the directory (or anything else) and return an error I can identify like either "not found" (if the network drive has another letter assigned for this user) or "access denied" if the user does not have the proper access rights. I guess I can use the Dir function as Tim suggested and use "on Error" statement to return if the user has access or not. But I don't know if there is a better function that would return an error code corresping to the inability to access the file instead of failing and creating an error in VBA. Charles On 9 May, 12:54, Dave Peterson wrote: Depending on what you're testing, why not just create a text file and try saving/deleting/renaming... the file. *If it fails on one of them, then they don't have that kind of access. Charles wrote: Hi Actually an easy one but I can't find anything on google. How can I check the access right to a folder (I just want to know if the user of the macro has access to a shared folder)? Is there any function that does that? (that would be on a network drive) thanks in advance Charles -- Dave Peterson |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What rights do you want the user to have?
Being able to open the file doesn't mean that they could update/save the file. Charles wrote: Hi Dave That's what I was thinking to initially. But I am a bit concerned about having a dozen of users doing it all the time and the potential pollution if the macro fails and files keep accumulating. Ideally it would be a function that does something like reading the directory (or anything else) and return an error I can identify like either "not found" (if the network drive has another letter assigned for this user) or "access denied" if the user does not have the proper access rights. I guess I can use the Dir function as Tim suggested and use "on Error" statement to return if the user has access or not. But I don't know if there is a better function that would return an error code corresping to the inability to access the file instead of failing and creating an error in VBA. Charles On 9 May, 12:54, Dave Peterson wrote: Depending on what you're testing, why not just create a text file and try saving/deleting/renaming... the file. If it fails on one of them, then they don't have that kind of access. Charles wrote: Hi Actually an easy one but I can't find anything on google. How can I check the access right to a folder (I just want to know if the user of the macro has access to a shared folder)? Is there any function that does that? (that would be on a network drive) thanks in advance Charles -- Dave Peterson -- Dave Peterson |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am just interested in the ability to read the file. So I guess
enything that could list the content of the folder would do the trick. I did this: Public Function HasAccessToFolder(ByVal FolderPath As String) As Boolean Dim St As String On Error GoTo ErrorHdlr HasAccessToFolder = True St = Dir(FolderPath) Exit Function ErrorHdlr: HasAccessToFolder = False Exit Function End Function but it obviously doesn't tell me what is wrong, just that something is wrong. Charles |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you're only interested if the user can open an excel file, you could turn off
error checking, try to open it readonly. If it's successful, then they have access to it. Dim wkbk as workbook set wkbk = nothing on error resume next set wkbk = workbooks.open(filename:="path.to.excel\something. xls", _ readonly:=true) on error goto 0 if wkbk is nothing then 'no access! else 'have access and the file is open end if Charles wrote: I am just interested in the ability to read the file. So I guess enything that could list the content of the folder would do the trick. I did this: Public Function HasAccessToFolder(ByVal FolderPath As String) As Boolean Dim St As String On Error GoTo ErrorHdlr HasAccessToFolder = True St = Dir(FolderPath) Exit Function ErrorHdlr: HasAccessToFolder = False Exit Function End Function but it obviously doesn't tell me what is wrong, just that something is wrong. Charles -- Dave Peterson |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Well, in this case I am interested in opening a huge access file. So
what I try to do is to first look at if I can have access to the folder, and then only I attempt a (time consuming) connection. |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you don't have access to the folder, then I bet that the time consumed will
be small. Charles wrote: Well, in this case I am interested in opening a huge access file. So what I try to do is to first look at if I can have access to the folder, and then only I attempt a (time consuming) connection. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check Folder For Files | Excel Discussion (Misc queries) | |||
Check if a folder has x files in it. | Excel Discussion (Misc queries) | |||
Check for file in folder | Excel Programming | |||
Check if folder exists, if yes just copy sheet in to folder? | Excel Programming | |||
check folder event | Excel Programming |