Consulting

Results 1 to 14 of 14

Thread: FileCopy to Network Drive

  1. #1
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location

    FileCopy to Network Drive

    hi,

    i'm trying to copy the file from local drive to SUNSERVER (192.168.64.70) network drive but it gives an error of "File not Found". the file is already exist in my local drive.

    [VBA]
    Sub CopyFile()

    FileCopy "C:\1.txt", "\\192.168.64.70\Manu\tm7211\In\1.txt"

    MsgBox "Done...", vbInformation, "File Copy"
    End Sub
    [/VBA]

    pls help..

    thanks,

  2. #2
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    gnod,

    From File Explorer, can you walk the file tree and get to the folder 'In'?

    What happens if you add a ChDir, like the following, and single-step your code? Does the file (1.txt in your code) exist on the destination?
    [vba]Sub CopyFile()

    ChDir "\\192.168.64.70\Manu\tm7211\In\"
    FileCopy "C:\1.txt", "\\192.168.64.70\Manu\tm7211\In\1.txt"

    MsgBox "Done...", vbInformation, "File Copy"
    End Sub[/vba]
    Cheers,
    Ron
    Windermere, FL

  3. #3
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location
    Thanks for your reply..

    i will try using ChDir..

    1.txt does not exist in the destination.. that will be the file that i want to copy.. if the destination is not a network drive, there is no problem with that syntax..

    ex: if i use this syntax then copy it to my other local drive, there is no error.

    [VBA]
    FileCopy "C:\1.txt", "D:\Manu\tm7211\In\1.txt"
    [/VBA]



    thanks..

  4. #4
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Just currious, have you tried mapping your drive first - say to drive K: and then copy the file. Maybe FileCopy command does not support UNC?

  5. #5
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    gnod,

    Can you perform your file copy from the dos box on you PC?
    c:\FileCopy "C:\1.txt", "\\192.168.64.70\Manu\tm7211\In\1.txt"
    Is 192.168.64.70 your PC or another machine? If not your PC, do you need to have write permission for it? If so, has it been set up for you? Just wondering.

    Cheers!
    Ron
    Windermere, FL

  6. #6
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location
    RonMck,

    ChDir doesn't work. it generates error "Path not Found".

    i didn't try FileCopy in a dos box because FileCopy is a VBA Statement not a command

    192.168.64.70 is a network drive, not my PC.. and it has a write permission on that folder..


    JKwan,
    i already tried maping the drive but still doesn't work.. it generate "File Not Found"..


    thanks,

  7. #7
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    gnod,

    So, instead of FileCopy you could try using Copy at the DOS prompt, however, I believe that will give the same 'file not found' error.

    Something is wrong in your path. I wouild use File Explorer to walk from '192.168.64.70' out to your destination subfolder: 'In'; you'll discover a difference between the path you've given us and the 'real' path.

    Thanks,
    Ron
    Windermere, FL

  8. #8
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location
    is there any other way rather than using the FileCopy Statement??

  9. #9
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Quote Originally Posted by RonMcK
    Something is wrong in your path. I wouild use File Explorer to walk from '192.168.64.70' out to your destination subfolder: 'In'; you'll discover a difference between the path you've given us and the 'real' path.
    Have you tested your path to verify that it is correct? Have you consulted with your network administrator?

    HTH,
    Ron
    Windermere, FL

  10. #10
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location
    the path is correct..
    what i do not know is the FileCopy can read the ip add of the other computer or is it only for local drive

  11. #11
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    I looked for help on the Microsoft Knowledgebase and found an article that's not quite your problem but may have some insights. It's in Access not Excel.

    http://support.microsoft.com/kb/207703/en-us

    I'm getting out of my depth. I hope some others will jump in and also help you with this issue.

    HTH,
    Ron
    Windermere, FL

  12. #12
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location
    thanks for your reply..

    i will try the API and the DOS command procedure when i get back to office..
    have you tried copying a file using copy command (DOS) to network drive?

  13. #13
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    gnod,

    I'm running a Mac here at work; when I attempt to chdir to a URL instead of a 'name' I get 'no such file or directory'. I asked one of our Help Desk to try it from her PC and she's unable to do it either.

    I think you'll need to get and use the 'name' of the server rather than its IP address. One advantage of this will be that your VBA Code will not break when or if the IP address changes for that other PC.

    HTH,
    Ron
    Windermere, FL

  14. #14
    VBAX Tutor gnod's Avatar
    Joined
    Apr 2006
    Posts
    257
    Location
    hi,

    i also experience "File not found" using the DOS command.
    in using API command i didn't get any error but it doesn't copy to the destination.
    i also try using the Computer name of the server instead of the ip address..



Posting Permissions

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