View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Eric G Eric G is offline
external usenet poster
 
Posts: 30
Default 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