I would like to be able to test if a user has access to a folder using VBA. Is this possible?
I would like to be able to test if a user has access to a folder using VBA. Is this possible?
I'd say that the easiest way would be to attempt to write a file to the folder.
Try this:
![]()
Function bHasFileAccess(sFolderPath As String) As Boolean Const sDefaultTestFileName="Test.txt" Dim iFileHandle As Integer Dim sInternalFolderPath As String On Error Goto ErrTrap sInternalFolderPath=Trim(sFolderPath) If Right(sInterNalFolderPath,1)<>"\" Then sInternalFolderPath=sInternalFolderPath & "\" End If iFileHandle=FreeFile Open sInternalFolderPath & sDefaultTestFileName For OutPut as iFileHandle Close#iFileHandle Kill sInternalFolderPath & sDefaultTestFileName bHasFileAccess=True Exit Function ErrTrap: bHasFileAccess=False End Function
Last edited by Andrew-R; 10-15-2010 at 10:12 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks