By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,486 Members | 2,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,486 IT Pros & Developers. It's quick & easy.

Why does fso.MoveFolder fail with "Permission denied"?

P: n/a
Why am I getting: "Error Number 70: Permission denied" when trying to move a
folder with the Microsoft Scripting Runtime?

Is there some security setting I don't know about?

Platform: Windows XP SP2 / Access 2003

Private Sub MoveFolder(strDestination As String)
'required references:
'Microsoft Office 11.0 Object Library
'Microsoft Scripting Runtime

Dim dlg As Office.FileDialog
Dim fso As Scripting.FileSystemObject
Dim varFldr As Variant

Set fso = New FileSystemObject
Set dlg = FileDialog(msoFileDialogFolderPicker)

'open folder picker dialog
dlg.AllowMultiSelect = False
If dlg.Show = True Then
For Each varFldr In dlg.SelectedItems
strSource = varFldr
Next

Debug.Print strSource & " => " & strDestination
'the paths look fine...

'move folder and its contents
If Len(strDestination) Then
fso.MoveFolder strSource, strDestination 'ERROR HERE
End If
End If

Set fso = Nothing
Set dlg = Nothing
End Sub

Is there a problem with this code or is it an OS issue?

Thanks in advance.

Jan 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Is there a possibility the account this database is running under does
not have write/modify permissions to either the source or destination
folders (or one level above)? It is my understanding that the
MoveFolder operation mimics a cut 'n' paste operation, which first
copies the object to the destination folder and then deletes it from
the source folder. The account needs to have permissions to delete the
source folder and modify the folder containing it, and permissions to
modify/write to the folder containing the destination folder.

Jan 10 '06 #2

P: n/a

"Steve" <th*********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Is there a possibility the account this database is running under does
not have write/modify permissions to either the source or destination
folders (or one level above)? It is my understanding that the
MoveFolder operation mimics a cut 'n' paste operation, which first
copies the object to the destination folder and then deletes it from
the source folder. The account needs to have permissions to delete the
source folder and modify the folder containing it, and permissions to
modify/write to the folder containing the destination folder.


But I can move files. Cut and paste these two functions into a standard
module and test from the immediate window with something like:

?MoveTheseFilesTo("C:\NewFolder1\")
(select any file from the dialog - NewFolder1 must exist)

and

?MoveThisFolderTo("C:\NewFolder2\")
(select any folder from the dialog - NewFolder2 must exist)

You'll get the same results - files get moved no problem, but folders get
hung up on "Error Number 70: Permission denied"

Public Function MoveTheseDocumentsTo(strDestination As String)
'required references:
'Microsoft Office 11.0 Object Library
'Microsoft Scripting Runtime

Dim varFile as Variant
Dim dlg As Office.FileDialog
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
Set dlg = FileDialog(msoFileDialogFilePicker)

strDestination = strDestination & varFile
If dlg.Show = True Then
For Each varFile In dlg.SelectedItems
fso.MoveFile varFile, strDestination
Next
End If

Set dlg = Nothing
Set fso = Nothing

End Function

Public Function MoveThisFolderTo(strDestination As String)
'required references:
'Microsoft Office 11.0 Object Library
'Microsoft Scripting Runtime

Dim strSource as String
Dim dlg As Office.FileDialog
Dim fso As Scripting.FileSystemObject
Dim varFldr As Variant

Set fso = New FileSystemObject
Set dlg = FileDialog(msoFileDialogFolderPicker)

'open folder picker dialog
dlg.AllowMultiSelect = False
If dlg.Show = True Then
For Each varFldr In dlg.SelectedItems
strSource = varFldr
Next

Debug.Print strSource & " => " & strDestination
'the paths look fine...

'move folder and its contents
If Len(strDestination) Then
fso.MoveFolder strSource, strDestination 'ERROR HERE
End If
End If

Set fso = Nothing
Set dlg = Nothing

End Function
Jan 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.