ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   moving a file to another folder (https://www.excelbanter.com/excel-programming/365367-moving-file-another-folder.html)

Chris

moving a file to another folder
 
does anyone have the code needed to move a file to another folder, or a way
of doing this through save as and then delete. The folder will be picked via
a variable.

Papou

moving a file to another folder
 
Hello
Please amend to your needs:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
fso.MoveFile "C:\test.xls", "C:\Temp\Test.xls"
If Err < 0 Then MsgBox "No such file exists", vbExclamation, "not found"
Set fso = Nothing

HTH
Cordially
Pascal
"Chris" a écrit dans le message de news:
...
does anyone have the code needed to move a file to another folder, or a
way
of doing this through save as and then delete. The folder will be picked
via
a variable.




Jim Rech

moving a file to another folder
 
Have a look at the VB Name statement in Help.

"The Name statement renames a file and moves it to a different directory or
folder, if necessary. "

--
Jim
"Chris" wrote in message
...
| does anyone have the code needed to move a file to another folder, or a
way
| of doing this through save as and then delete. The folder will be picked
via
| a variable.



Don Guillett

moving a file to another folder
 
Would you believe it's this easy

Sub movefile()
OldName = "C:\oldfolder\filename.xls"
NewName = "C:\newfolder\filename.xls"
Name OldName As NewName
End Sub

--
Don Guillett
SalesAid Software

"Chris" wrote in message
...
does anyone have the code needed to move a file to another folder, or a
way
of doing this through save as and then delete. The folder will be picked
via
a variable.





All times are GMT +1. The time now is 09:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com