Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Moving a file

In cell A6 is a new value(Full file path) and in cell A7
is the old value(Full file path).
For instance: Cell A6 = P:\My Stats.xls
and Cell A7= C:\Config\My Stats.xls

What is the code to move the file from the old file path
to the new file path? In this case I will need My
Stats.xls to be moved from C:\Config to P:\.

This can be done by copying the file and deleting the file
in the old path or by just moving it.

It really does not matter I just need the file moved on
the above criteria.

Thank you

Todd Huttenstine
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Moving a file

Hi Todd

I think this'll work (but not heavy-duty tested):

Sub test()
Name "C:\Temp\Book1.xls" As "D:\Data\Book1.xls"
End Sub

if not then here's the more traditional way; copy and delete:

Sub test2()
Dim FileFrom As String
Dim FileTo As String
FileFrom = "D:\Data\Book1.xls"
FileTo = "C:\Temp\Book1.xls"
FileCopy FileFrom, FileTo
DoEvents
If Dir(FileTo) < "" Then Kill FileFrom
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Todd Huttenstine" wrote in message
...
In cell A6 is a new value(Full file path) and in cell A7
is the old value(Full file path).
For instance: Cell A6 = P:\My Stats.xls
and Cell A7= C:\Config\My Stats.xls

What is the code to move the file from the old file path
to the new file path? In this case I will need My
Stats.xls to be moved from C:\Config to P:\.

This can be done by copying the file and deleting the file
in the old path or by just moving it.

It really does not matter I just need the file moved on
the above criteria.

Thank you

Todd Huttenstine



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Moving a file

Oh sorry, I cant make it static in the code because the
values in both of the cells will change.

Thanx
-----Original Message-----
Hi Todd

I think this'll work (but not heavy-duty tested):

Sub test()
Name "C:\Temp\Book1.xls" As "D:\Data\Book1.xls"
End Sub

if not then here's the more traditional way; copy and

delete:

Sub test2()
Dim FileFrom As String
Dim FileTo As String
FileFrom = "D:\Data\Book1.xls"
FileTo = "C:\Temp\Book1.xls"
FileCopy FileFrom, FileTo
DoEvents
If Dir(FileTo) < "" Then Kill FileFrom
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Todd Huttenstine"

wrote in message
...
In cell A6 is a new value(Full file path) and in cell A7
is the old value(Full file path).
For instance: Cell A6 = P:\My Stats.xls
and Cell A7= C:\Config\My Stats.xls

What is the code to move the file from the old file path
to the new file path? In this case I will need My
Stats.xls to be moved from C:\Config to P:\.

This can be done by copying the file and deleting the

file
in the old path or by just moving it.

It really does not matter I just need the file moved on
the above criteria.

Thank you

Todd Huttenstine



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Moving a file

Oh thanx, I got it to work.
-----Original Message-----
Hi Todd

I think this'll work (but not heavy-duty tested):

Sub test()
Name "C:\Temp\Book1.xls" As "D:\Data\Book1.xls"
End Sub

if not then here's the more traditional way; copy and

delete:

Sub test2()
Dim FileFrom As String
Dim FileTo As String
FileFrom = "D:\Data\Book1.xls"
FileTo = "C:\Temp\Book1.xls"
FileCopy FileFrom, FileTo
DoEvents
If Dir(FileTo) < "" Then Kill FileFrom
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Todd Huttenstine"

wrote in message
...
In cell A6 is a new value(Full file path) and in cell A7
is the old value(Full file path).
For instance: Cell A6 = P:\My Stats.xls
and Cell A7= C:\Config\My Stats.xls

What is the code to move the file from the old file path
to the new file path? In this case I will need My
Stats.xls to be moved from C:\Config to P:\.

This can be done by copying the file and deleting the

file
in the old path or by just moving it.

It really does not matter I just need the file moved on
the above criteria.

Thank you

Todd Huttenstine



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Moving a file

With no testing at all!

Sub test()
with activesheet
Name .range("a7").value As .range("a6").value
End Sub

if not then here's the more traditional way; copy and delete:

Sub test2()
Dim FileFrom As String
Dim FileTo As String
FileFrom = activesheet.range("a7").value
FileTo = activesheet.range("a6").value
FileCopy FileFrom, FileTo
DoEvents
If Dir(FileTo) < "" Then Kill FileFrom
End Sub

Todd Huttenstine wrote:

Oh sorry, I cant make it static in the code because the
values in both of the cells will change.

Thanx
-----Original Message-----
Hi Todd

I think this'll work (but not heavy-duty tested):

Sub test()
Name "C:\Temp\Book1.xls" As "D:\Data\Book1.xls"
End Sub

if not then here's the more traditional way; copy and

delete:

Sub test2()
Dim FileFrom As String
Dim FileTo As String
FileFrom = "D:\Data\Book1.xls"
FileTo = "C:\Temp\Book1.xls"
FileCopy FileFrom, FileTo
DoEvents
If Dir(FileTo) < "" Then Kill FileFrom
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Todd Huttenstine"

wrote in message
...
In cell A6 is a new value(Full file path) and in cell A7
is the old value(Full file path).
For instance: Cell A6 = P:\My Stats.xls
and Cell A7= C:\Config\My Stats.xls

What is the code to move the file from the old file path
to the new file path? In this case I will need My
Stats.xls to be moved from C:\Config to P:\.

This can be done by copying the file and deleting the

file
in the old path or by just moving it.

It really does not matter I just need the file moved on
the above criteria.

Thank you

Todd Huttenstine



.


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Moving a file

Todd

Sure, deliberate twist. I -and many others- rarely post
ready-to-use-with-error-trapping-included code. If you have to read it, consider,
implement and adjust it yourself then you will also hopefully understand and remember it.
Perhaps I can build the whole thing for you, but that's not help. That's work.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Todd Huttenstine" wrote in message
...
Oh sorry, I cant make it static in the code because the
values in both of the cells will change.

Thanx




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
Moving Worksheets From One File to Another dcapps Excel Discussion (Misc queries) 1 August 4th 09 05:33 PM
Moving a sheet from one Excel file to another? Kathy Excel Discussion (Misc queries) 6 April 28th 09 03:32 PM
Moving data from one excel file to another audif New Users to Excel 4 June 5th 07 06:37 PM
Moving file locations Derek Links and Linking in Excel 1 August 9th 06 12:45 AM
moving file from excel to word Clovis Excel Discussion (Misc queries) 2 April 8th 06 04:28 PM


All times are GMT +1. The time now is 05:22 PM.

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"