+ Reply to Thread
Results 1 to 2 of 2

Test Securtiy on Folder

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Test Securtiy on Folder

    I would like to be able to test if a user has access to a folder using VBA. Is this possible?

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Test Securtiy on Folder

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1