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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving a file from one folder to the next 1

Status
Not open for further replies.

leonepaolo

Programmer
May 28, 2001
82
CA
Hi, I'm at my wits end here. I've been at this on and off for ages. I just can't get it. I've looked it up in the help file. I've googled it. I'm going bonkers.

Finally I figured out a work around, but there's got to be a better way than this:

FileCopy a,b
Kill a

I must be missing a reference or somthing. When I do:

Move a,b
I get Run-time error '1004'
Application-defined or object-defined error.

MoveFile a,b
this generates sub or function not defined.

I've looked up FileSystemObject and a few others, but I can't put it together.

Please help.
 
Name OldName As NewName ' Rename file
 
Other than your subject line you are rather sparse on details - neither stating what application you are using, or what exactly you have tried. However,
Code:
Sub MoveMyFile()
Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Set fso = CreateObject("Scripting.FileSystemObject")
Set fil = fso.GetFile("C:\test\bob0.doc")
  fil.Move "c:\temp\"
Set fil = Nothing
Set fso = Nothing
End Sub
works fine for me. It moves the file. It may need to be adjusted for what you are trying to do....but I don't know what that is, as you don't say.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top