Why am I keeping have this error in VBA
Results 1 to 3 of 3

Thread: Why am I keeping have this error in VBA
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular eliW's Avatar
    Join Date
    Mar 2002
    Posts
    1,923
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Why am I keeping have this error in VBA

    Hi all,
    I am trying to copy files from a folder and subfolders to another destination according to list in first column of a worksheet.
    BTW, the list contains full path and file name like this:
    HTML Code:
    713It's My Party -Lesley Gore.mp3	F:\A04
    714Sleep walk -Santo and Johnny.mp3	F:\A04
    Exexcuting this macro gives me a constant error on the red line saying:
    PHP Code:
    Run Time Error 70
    Permission Denied 
    Code:
    Sub copyfiles()
    'copy files from folder and subfolders to another folders
    
    Dim m, x As Variant
    Dim Copier
    Dim FileName As String
    Dim FileType As String
    Dim FilePath As String
    
    'On Error Resume Next
    m = Range("A1").CurrentRegion.Count
    
    Set Copier = CreateObject("Scripting.FileSystemObject")
    For x = 1 To m
    FileName = Cells(x, 1).Value
    FilePath = Cells(x, 2).Value
    'Copier.copyfile "C:\Users\User\Desktop\rivka\" & FileName, "C:\Users\User\Desktop\songs\"
    Copier.copyfile FilePath & "\" & FileName, "C:\Users\User\Desktop\jjj"
    'Copier.copyfile FileName, "C:\Users\User\Desktop\jjj"
    Next
    MsgBox ("done")
    '
    End Sub
    Any help will be apreciated,
    Eli
    Eli

  2. #2
    Board Regular
    Join Date
    May 2013
    Posts
    628
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Why am I keeping have this error in VBA

    I assume you can copy there manually.?
    Code:
    You will need a "\" after any path.? You do not have one in "C:\Users\User\Desktop\jjj" yet you put one in FilePath & "" & FileName ?
    Last sentence in code tags as site removes the \ otherwise?
    Last edited by welshgasman; Dec 31st, 2018 at 06:58 AM.
    Office 2007
    Access novice. Sometimes trying to give something back

  3. #3
    Board Regular eliW's Avatar
    Join Date
    Mar 2002
    Posts
    1,923
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Why am I keeping have this error in VBA

    Quote Originally Posted by welshgasman View Post
    I assume you can copy there manually.?
    Code:
    You will need a "\" after any path.? You do not have one in "C:\Users\User\Desktop\jjj" yet you put one in FilePath & "" & FileName ?
    Last sentence in code tags as site removes the \ otherwise?
    Hi welshgasman,
    This indeed was the problem -simple slash.
    Thank you very much,
    Eli
    Eli

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •