Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Move file to different folder

try

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

"Michael Bond" wrote in message
...
Hello all

I have created a project to open all files in a folder,
perform some work with the data in the file(s), set the
file save property as true and close the file.

I now want to move the file out of that folder into
another. I just cannot get my head round the code I need
to do that.

Sample of my code attached....can any one provide
the '????????? line which is moving the file out of the
folder into a different folder.

Much obliged for your attention

Regards

Michael Bond

Sub WorkOnFile()

Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("X:\******** *******\")
Set fc = f.Files


For Each f1 In fc

'(Various code here which opens file and carries
out some work then...)

ActiveWorkbook.Saved = True
ActiveWorkbook.Close

'????????????????

Next



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Move file to different folder

Don

thanks....this indeed works and creates the file in the
new directory....but....it retains the original file in
the original directory....something I want to avoid so
that it does not get processed again the next time the
project is run

Any further thoughts?

Regards

Michael Bond

-----Original Message-----
try

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

"Michael Bond" wrote in

message
...
Hello all

I have created a project to open all files in a folder,
perform some work with the data in the file(s), set the
file save property as true and close the file.

I now want to move the file out of that folder into
another. I just cannot get my head round the code I need
to do that.

Sample of my code attached....can any one provide
the '????????? line which is moving the file out of the
folder into a different folder.

Much obliged for your attention

Regards

Michael Bond

Sub WorkOnFile()

Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("X:\******** *******\")
Set fc = f.Files


For Each f1 In fc

'(Various code here which opens file and carries
out some work then...)

ActiveWorkbook.Saved = True
ActiveWorkbook.Close

'????????????????

Next



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Move file to different folder

Don

thanks....this indeed works and creates the file in the
new directory....but....it retains the original file in
the original directory....something I want to avoid so
that it does not get processed again the next time the
project is run

Any further thoughts?

Regards

Michael Bond

-----Original Message-----
try

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

"Michael Bond" wrote in

message
...
Hello all

I have created a project to open all files in a folder,
perform some work with the data in the file(s), set the
file save property as true and close the file.

I now want to move the file out of that folder into
another. I just cannot get my head round the code I need
to do that.

Sample of my code attached....can any one provide
the '????????? line which is moving the file out of the
folder into a different folder.

Much obliged for your attention

Regards

Michael Bond

Sub WorkOnFile()

Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("X:\******** *******\")
Set fc = f.Files


For Each f1 In fc

'(Various code here which opens file and carries
out some work then...)

ActiveWorkbook.Saved = True
ActiveWorkbook.Close

'????????????????

Next



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Move file to different folder

I just re-tested using xp home and xl2002 and it MOVED the file as it
should.
I moved a file from c:\personal to c:\a
I assume that both directories do exist.

"Michael Bond" wrote in message
...
Don

thanks....this indeed works and creates the file in the
new directory....but....it retains the original file in
the original directory....something I want to avoid so
that it does not get processed again the next time the
project is run

Any further thoughts?

Regards

Michael Bond

-----Original Message-----
try

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

"Michael Bond" wrote in

message
...
Hello all

I have created a project to open all files in a folder,
perform some work with the data in the file(s), set the
file save property as true and close the file.

I now want to move the file out of that folder into
another. I just cannot get my head round the code I need
to do that.

Sample of my code attached....can any one provide
the '????????? line which is moving the file out of the
folder into a different folder.

Much obliged for your attention

Regards

Michael Bond

Sub WorkOnFile()

Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("X:\******** *******\")
Set fc = f.Files


For Each f1 In fc

'(Various code here which opens file and carries
out some work then...)

ActiveWorkbook.Saved = True
ActiveWorkbook.Close

'????????????????

Next



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Move file to different folder

glad to help.

"Michael Bond" wrote in message
...
Don

erm...apologies and humble pie....I don't know what I did
wrong first time....

Thanks for your patience and the help.

Regards

Michael Bond
-----Original Message-----
I just re-tested using xp home and xl2002 and it MOVED

the file as it
should.
I moved a file from c:\personal to c:\a
I assume that both directories do exist.

"Michael Bond" wrote in

message
...
Don

thanks....this indeed works and creates the file in the
new directory....but....it retains the original file in
the original directory....something I want to avoid so
that it does not get processed again the next time the
project is run

Any further thoughts?

Regards

Michael Bond

-----Original Message-----
try

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

"Michael Bond" wrote in
message
...
Hello all

I have created a project to open all files in a

folder,
perform some work with the data in the file(s), set

the
file save property as true and close the file.

I now want to move the file out of that folder into
another. I just cannot get my head round the code I

need
to do that.

Sample of my code attached....can any one provide
the '????????? line which is moving the file out of

the
folder into a different folder.

Much obliged for your attention

Regards

Michael Bond

Sub WorkOnFile()

Dim fs, f, f1, fc, s
Set fs = CreateObject

("Scripting.FileSystemObject")
Set f = fs.GetFolder("X:\******** *******\")
Set fc = f.Files


For Each f1 In fc

'(Various code here which opens file and

carries
out some work then...)

ActiveWorkbook.Saved = True
ActiveWorkbook.Close

'????????????????

Next



.



.



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
Move Active Workbook to another Folder jonallen51 Excel Discussion (Misc queries) 0 March 12th 08 07:41 PM
Any problem if i move a shared folder from my desktop to d drive shanavas Excel Discussion (Misc queries) 1 December 16th 07 03:22 PM
move a sheet out of my workbook and place in another folder? trishb123 Excel Discussion (Misc queries) 3 January 10th 07 04:14 PM
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


All times are GMT +1. The time now is 04:59 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"