Permission Denied

  • Thread starter Thread starter Varne
  • Start date Start date
V

Varne

Hello

I have a procedue to list down my files in my computer onto an Excel Sheet.

It worked perfectly. Actually I got it from this forum.

However I get the above error message.

Help gives 4 explanations including something like 'I have tried to
something with registry" or "I have tried to open a file for sequencial
output and append".

But why now? Why not before?

Thank You
M Varnendra
 
It would be helpful to see your code. It also might be helpful to know what
it's trying to access when it give this error.
 
Hi Mate

Here you go;

Sub FileListing()

Dim FSO As Scripting.FileSystemObject
Dim FF As Scripting.Folder
Dim StartFolder As String
Dim StartCell As Range
Dim Indent As Boolean
Dim ListFiles As Boolean

StartFolder = InputBox("Enter folder path:")
If StartFolder = vbNullString Then
Exit Sub
End If
If Dir(StartFolder, vbDirectory) = vbNullString Then
Exit Sub
End If
On Error Resume Next
Set StartCell = Application.InputBox( _
prompt:="Select start cell.", Type:=8)
If StartCell Is Nothing Then
Exit Sub
End If
On Error GoTo 0

Indent = MsgBox("Indent listing?", vbYesNo) = vbYes
ListFiles = MsgBox("List files?", vbYesNo) = vbYes


Set FSO = New Scripting.FileSystemObject
Set FF = FSO.GetFolder(StartFolder)
DoFolder FF, StartCell, ListFiles, Indent


End Sub

Sub DoFolder(FF As Scripting.Folder, R As Range, ListFiles As Boolean,
Indent As Boolean)

Dim F As Scripting.File
Dim SubF As Scripting.Folder

R.Value = FF.Path
If Indent = True Then
Set R = R(1, 2)
End If
If ListFiles = True Then
For Each F In FF.Files
Set R = R(2, 1)
R.Value = F.Name
Next F
End If
Set R = R(2, 1)
For Each SubF In FF.SubFolders
DoFolder SubF, R, ListFiles, Indent
Next SubF
If Indent Then
Set R = R(1, 0)
End If

End Sub

When Done Before Now

C:\ C:\
autoexec.bat autoexec.bat
bootmgr bootmgr
config.sys config.sys
dell.sdr dell.sdr
hiberfil.sys hiberfil.sys
newfile.enc newfile.enc
newkey newkey
pagefile.sys pagefile.sys
C:\$RECYCLE.BIN C:\$RECYCLE.BIN
CIMA.doc desktop.ini desktop.ini
Dat.xlsx C:\$RECYCLE.BIN\ C:\$RECYCLE.BIN\

The code stops with C:\$RECYCLE.BIN\----------- (I ahve taken out the
digits). Almost all my directories and files are in C.

Thanks
 
Back
Top