Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rookie_User,
Are your names fully qualified? For example, you need to use C:\MoveFrom\test.txt rather than test.txt. Have you looked over the help documentation for MoveFile Method (i.e. you know how source should be set up and you know the implications of leaving off "\" for destination)? Also, you may want to consider the Name Statement (see the VBE Help files for this). Without me creating any code to mirror what you are doing, I would start by examining the help documentation and ensure that your arguments are correct. Best, Matthew Herbert "Rookie_User" wrote: I am trying to move a file from one folder to another - or at least copy and delete the old file. I get an error 58 file already exists, and don't know why? Public Sub MoveFiles(ByVal Source As String, ByVal Destination As String) Dim oFSO As Object Set oFSO = CreateObject("Scripting.FileSystemObject") With oFSO If .FileExists(Source) Then .MoveFile Source, Destination Else MsgBox Source & " Doesn't Exist", vbExclamation End If End With Set oFSO = Nothing End Sub Sub RunThroughList() Dim I As Long Dim Destination As String Dim Lastrow As Long Lastrow = Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Row For I = 1 To Lastrow MoveFiles Range("A" & I).Value, "C:\Output" Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Check if a sheet exists in a file, without opening that file | Excel Programming | |||
Error - file already exists. | Excel Programming | |||
Error if 'name' already exists | Excel Programming | |||
File Name Exists Error Trap | Excel Programming | |||
the file already exists - do you want to replace the existing file? | Excel Programming |