Consulting

Results 1 to 7 of 7

Thread: Folder Access

  1. #1

    Exclamation Folder Access

    Hello All

    I need help to figure out the access type to a list of folders as whether Read/write, read only or view only. Is there a way to find using VBA? Appreciate any help.

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Sub tst()
        MsgBox CreateObject("scripting.filesystemobject").getfolder("G:\OF").Attributes
    End Sub

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
      MsgBox "e:\t: " & ((GetAttr("e:\t") And vbReadOnly) <> 0), vbInformation, "ReadOnly?"
      MsgBox "e:\t: " & ((CreateObject("scripting.filesystemobject").GetFolder("e:\t").Attributes And vbReadOnly) <> 0), vbInformation, "ReadOnly?"

  4. #4
    Thanks for your replies. There are 3 possibilities. I could have read/write access, read only access where I can read and copy files from, a view only access where I can view files but cannot open or copy them and lastly no access. How do I derive this information. The attributes properties is returning 48 for all the above possibilities.

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    I showed how to do it. It is also explained in the help for the VBA command GetAttr. Type GetAttr and press F1 or browse the it by F2 and press F1 when you select it there for more help.

  6. #6
    Hi Kenneth

    It returns 48 for read only folders. Not sure what the number is. For folders I dont have access to, it returns 48 or nothing at all which is confusing. Also there are some folders where I have view access but not access to copy files from unlike read only folders and it still returns 48.

  7. #7
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Did you look at the help as I advised?

    There is no value of 48 for a single attribute. It is a summed number of the attributes that is returned. The help explains how to use the bitwise AND operator to parse out the attribute that you want to check. If the bitwise operationr result is not 0, then the attribute is set. Does my code now make sense?

Posting Permissions

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