Changing folder attributes - Run-time error ‘70’: permission denied

DavidSCowan

Board Regular
Joined
Jun 7, 2009
Messages
78
Can someone help me please.

I am trying map out my hard drive – which files are in which folder, folder sizes etc.. This requires that I access folders.

The problem is that if the folder attribute is not normal i.e. folder.attribute is not =0 then when the procedure runs I get: Run-time error ‘70’: permission denied.

When the folder isn’t normal what I want to do is to change the folder attribute from Read-Only = 1, Hidden = 2 (or one of the many other numbers), carry out the procedure and then reset the original attribute after the procedure .

The problem is that when I try to do this I again get “Run-error ‘70’: permission denied”!

The relevant part of the procedure is:

Dim apexfolder as scripting.folder

Set apexfolder = fso.GetFolder(FolderToSearch)

folderType = apexfolder.Attributes ‘This is to reset the folder attribute back to what it was later

If folderType = 0 Then

'Do nothing
Else

apexfolder.Attributes = 0 ‘Here I am trying to set the folder type to normal but this generates Run-time error 70

THE PROCEDURE

apexfolder.Attributes= folderType 'resetting back to the original type

Any thoughts gratefully received.

With kind regards

David
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top