Consulting

Results 1 to 4 of 4

Thread: Copy files runtime error 70 when trying to copy

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Oct 2007
    Posts
    97
    Location

    Copy files runtime error 70 when trying to copy

    Hey Guys,
    I am using VBA to copy a file from one folder already on the desktop (From Path), to another folder (ToPath) I create through VBA on the desktop.
    ToPath = tempPath & "Documents and Settings" & "\" & tempUser & "\" & "Desktop" & "\" & FolderName
    Everything goes fine up until the copy command where I have a runtime error 70, permission denied.
    Set FSO = CreateObject("scripting.filesystemobject")
    FSO.CopyFile Source:=FromPath & FileName, Destination:=ToPath
    I did some troubleshooting, and noticed that if I manually create the "ToPath" folder, the file gets copied without any error.

    Am I forgetting something to declare?
    Have anyone faced such error?

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    How are you creating the folder on the desktop? As shown, if FolderName ends in a path seperator, Foldername must already exist. If no trailing path seperator is in FolderName, Foldername becomes the name of the copied file (which would be created on the desktop).

  3. #3
    VBAX Regular
    Joined
    Oct 2007
    Posts
    97
    Location
    GTO, You are totally right. I added a path separator and it worked.
    ToPath = tempPath & "Documents and Settings" & "\" & tempUser & "\" & "Desktop" & "\" & FolderName & "\"
    Thanks.

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Fadib,

    You are most welcome :-)

    If solved, there is an option under Thread Tools (that will show only to you, the thread's initiator) to mark the thread "Solved". This saves "answerers" time in checking.

    Mark

Posting Permissions

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