Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA to Move Files 2

Status
Not open for further replies.

perrymans

IS-IT--Management
Nov 27, 2001
1,340
US
I am importing files and want to change their location once imported.

After the import completes successfully, I would like to move the list of files to a different folder.

I know how I would allow the user to set the path to the folder, I just don't know the command to move a file.

Thanks. Sean.
 
Or this:
Code:
MoveFile Method
         

Description

Moves one or more files from one location to another.

Syntax

object.MoveFile source, destination 

The MoveFile method syntax has these parts:

Part Description 
object Required. Always the name of a FileSystemObject. 
source Required. The path to the file or files to be moved. The source argument string can contain wildcard characters in the last path component only. 
destination Required. The path where the file or files are to be moved. The destination argument can't contain wildcard characters.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Make sure you have a project reference set to the Microsoft Scripting Runtime library:
Code:
Dim fso As Scripting.FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
'....your code
Set fso = Nothing

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
No need of any object:
Name oldpathname As newpathname

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry PHV, I don't think I understand what you are saying.
 
Name is a native VBA instruction to move file

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top