ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Easy Way to Check File Privileges? (https://www.excelbanter.com/excel-programming/427664-easy-way-check-file-privileges.html)

Eric G

Easy Way to Check File Privileges?
 
I am recursively looping through a folder hierarchy, and then through all the
files in each folder. As part of my process, I need to check my ability to
open each of the files (i.e. do I have the correct permission) for read or
read/write. Is there a quick way to do this in VBA without actually trying
to open each file?

Here is some fragmentary code to illustrate my use of variables (from the
NG, of course):

Dim fso As Scripting.FileSystemObject
Dim oDir As Folder
Dim fSubDir As Folder ' Used for recursion...
Dim oFile As File

....

Set fso = CreateObject("Scripting.FileSystemObject")
Set oDir = fso.getfolder(strPath)

....

For Each oFile In fSubDir.Files
' check to see if I have "Read" or "Read/Write" permission for each
file
' and report those for which I don't
Next oFile

Thanks in advance,

Eric


All times are GMT +1. The time now is 11:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com