Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
tvt
 
Posts: n/a
Default VBA to move an excel file to another folder

Hello,

I want to write a macro that takes an existing excel file (workbook) and
place it in another folder. Basically something that would simulate cutting
a file from one folder and pasting it in another. Is this possible using
VBA? If it is, what would be the code or where can i find the code to do so?
Thanks!
  #2   Report Post  
Harald Staff
 
Posts: n/a
Default

Hi

It's very easy, given that the file and the to-folder already exist:

Sub MoveFile()
Name "C:\Temp\Book1.xls" As "C:\Junk\Book5.xls"
End Sub

HTH. Best wishes Harald

"tvt" skrev i melding
...
Hello,

I want to write a macro that takes an existing excel file (workbook) and
place it in another folder. Basically something that would simulate

cutting
a file from one folder and pasting it in another. Is this possible using
VBA? If it is, what would be the code or where can i find the code to do

so?
Thanks!



  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

Look up Name in VBA's help.

Or even FileCopy and Kill.

These options will work if that file (doesn't have to be an excel workbook)
isn't open.

tvt wrote:

Hello,

I want to write a macro that takes an existing excel file (workbook) and
place it in another folder. Basically something that would simulate cutting
a file from one folder and pasting it in another. Is this possible using
VBA? If it is, what would be the code or where can i find the code to do so?
Thanks!


--

Dave Peterson
  #4   Report Post  
Junior Member
 
Posts: 1
Default

Hi, Is there any way to move the files even if they are open? I am specifically working on excel files. There is a button in the file and the code checks the name and moves all excel files that have that keyword as part of the filename and move it to a different folder. The code works except for the open files. Can you please help? I tried to use the Name function, Copy and Kill, Move, and nothing worked with open files.

I appreciate the help ... Thanks

Quote:
Originally Posted by Dave Peterson View Post
Look up Name in VBA's help.

Or even FileCopy and Kill.

These options will work if that file (doesn't have to be an excel workbook)
isn't open.

tvt wrote:

Hello,

I want to write a macro that takes an existing excel file (workbook) and
place it in another folder. Basically something that would simulate cutting
a file from one folder and pasting it in another. Is this possible using
VBA? If it is, what would be the code or where can i find the code to do so?
Thanks!


--

Dave Peterson
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
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
Excel 2000 file when opened in Excel 2003 generates errors? Doug Excel Discussion (Misc queries) 13 December 25th 04 10:20 PM
double click a xls file and start Excel but without the file Danyi, Attila Excel Discussion (Misc queries) 2 December 22nd 04 02:19 PM
Saving a Excel 97 file into Excel 2003 file Wil Excel Discussion (Misc queries) 1 December 13th 04 11:51 PM


All times are GMT +1. The time now is 06:24 AM.

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

About Us

"It's about Microsoft Excel"