VBA Error 70 Permission Denied RRS feed

  • Question

  • Hi Guys,

    I am trying to copy and paste some of the specific files using excel sheet and VBA. However, I have encountered an issue with my FSO.CopyFiles line. It should be simple VBA but it has been giving me so much pain because I cannot fix the issue. Please help.


    'In this Example I am Copying the File From one loaction to another location
    'as per the details specified in the Worksheet.

    Sub BLCopyingFromSheet()
        Dim K As Integer
        Dim A As Integer
        Dim lastRow As Long
        Dim FSO As Object
        Set FSO = CreateObject("Scripting.FileSystemObject")
        For K = 1 To 40
            If Not Cells(K, 2) = "" Then lastRow = K

        For A = 8 To lastRow
            Dim sFile As String
            Dim sSFolder As String
            Dim SDFolder As String
            Dim sFileVal As String
            sFile = ActiveSheet.Cells(A, 2)
            sFileVal = ActiveSheet.Cells(A, 2).Value
            sSFolder = ActiveSheet.Range("B6")
            SDFolder = ActiveSheet.Cells(A, 4).Value
            If Not FSO.FileExists(sSFolder & sFile) Then

            MsgBox "Can't find the files: " & vbNewLine & sFileVal, vbInformation, "File Not Found"

            ElseIf Not FSO.FileExists(SDFolder & sFile) Then
            FSO.CopyFile (sSFolder & sFile), SDFolder, True

            Else: MsgBox "Same Files exist:" & vbNewLine & sFileVal, vbExclamation, "File Already Exists"

            End If
        Next A

    End Sub


    • Moved by Bill_Stewart Friday, March 15, 2019 7:22 PM This is not "fix/debug/rewrite my script for me" forum
    Monday, February 11, 2019 5:31 AM

All replies

  • Sorry but this is not a VBA forum.  This forum is for administrative scripting.  You want the "Office VBA" forum.

    Also note that you cannot access files that you do not have permission on.  Get permission to access the file.


    • Edited by jrv Monday, February 11, 2019 6:28 AM
    Monday, February 11, 2019 6:25 AM