Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
Buttons Fail After Moving File to Different Folder Dave Brodak Excel Programming 1 December 23rd 05 04:52 PM
Moving a file from one folder to another scantor145[_11_] Excel Programming 2 June 30th 05 03:38 PM
Moving a folder asmenut Excel Programming 4 October 24th 04 10:29 PM
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM


All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"