#1   Report Post  
Dave
 
Posts: n/a
Default Macro to move file

Is there a way to use a macro in a workbook to move a file from one folder to
another folder by copying it? I tried to record a macro to do it but nothing
shows up in the VB editor.

Thanks
Dave
  #2   Report Post  
Kassie
 
Posts: n/a
Default Macro to move file

Hi Dave

Try the following?

Sub SaveCopy()
ChDir "C:\Documents and Settings\{Enter new Directory name here}"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\{Enter new directory and file name here},
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

This is the result of running Macro Record, but you can adapt it to suit
your needs.

--
ve_2nd_at. Randburg, Gauteng, South Africa


"Dave" wrote:

Is there a way to use a macro in a workbook to move a file from one folder to
another folder by copying it? I tried to record a macro to do it but nothing
shows up in the VB editor.

Thanks
Dave

  #3   Report Post  
Dave O
 
Posts: n/a
Default Macro to move file

Yes there is- how do you want to handle the files? For instance, do
you want to save the original file in the original location, and make a
copy of the file to the new folder? Or do you want to skip right to
the Save As to the new folder, and delete the file from the original
location?

It's easily done, and for the most part can be accomplished by
recording the macro. Why the macro didn't show up in the editor is
troublesome but most likely easily overcome.

  #4   Report Post  
Don Guillett
 
Posts: n/a
Default Macro to move file

Actually one of the easier things to do.

Sub movefile()
OldName = "C:\oldfoldername\1065.xls"
NewName = "C:\newfoldername\1065.xls"
Name OldName As NewName
End Sub

--
Don Guillett
SalesAid Software

"Dave" wrote in message
...
Is there a way to use a macro in a workbook to move a file from one folder

to
another folder by copying it? I tried to record a macro to do it but

nothing
shows up in the VB editor.

Thanks
Dave



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 65
Default Macro to move file

Dave - I want to do exactly what you have outlined here. I want to do the
save as and delete the file from the original location. I used record macro
and the save-as worked just fine. The delete file is the part I am having
trouble with. All I could think to do was a file-open and then delete the
file there. It didn't work. It just gave me the ChDir and leaves the
original file there. What do you suggest? Pam

"Dave O" wrote:

Yes there is- how do you want to handle the files? For instance, do
you want to save the original file in the original location, and make a
copy of the file to the new folder? Or do you want to skip right to
the Save As to the new folder, and delete the file from the original
location?

It's easily done, and for the most part can be accomplished by
recording the macro. Why the macro didn't show up in the editor is
troublesome but most likely easily overcome.




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Macro to move file

Pam,

Dim myFName As String
myFName = ActiveWorkbook.Fullname 'or use some other workbook object that points to the file

'Do your SaveAs, then use

Kill myFName


HTH,
Bernie
MS Excel MVP


"Pam M" wrote in message
...
Dave - I want to do exactly what you have outlined here. I want to do the
save as and delete the file from the original location. I used record macro
and the save-as worked just fine. The delete file is the part I am having
trouble with. All I could think to do was a file-open and then delete the
file there. It didn't work. It just gave me the ChDir and leaves the
original file there. What do you suggest? Pam

"Dave O" wrote:

Yes there is- how do you want to handle the files? For instance, do
you want to save the original file in the original location, and make a
copy of the file to the new folder? Or do you want to skip right to
the Save As to the new folder, and delete the file from the original
location?

It's easily done, and for the most part can be accomplished by
recording the macro. Why the macro didn't show up in the editor is
troublesome but most likely easily overcome.




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
VBA to move an excel file to another folder tvt Excel Discussion (Misc queries) 3 December 19th 13 02:53 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
move to another cell within a subtotal report within a macro NoelH Excel Worksheet Functions 1 August 31st 05 03:02 PM
Problem Editing Macro in Shared Excel File [email protected] Excel Discussion (Misc queries) 0 March 19th 05 06:01 PM
creat a macro to look for a file Kelly****** Excel Discussion (Misc queries) 1 January 2nd 05 09:24 AM


All times are GMT +1. The time now is 07:01 PM.

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"