Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Move & Rename File

  Asked By: Pamela    Date: Mar 02    Category: MS Office    Views: 628
  

I am moving a file from one folder to another folder in the same
directory. I would like the new file name to be as the old file name.
The current code is not working. The problem is in the "Name OldName
As NewName". The wildcard is used because each day there will be
different file that is being downloaded to the Schedule folder from the
bank that needs to be moved & reformatted for the purposes of importing
it to the accounting application. Thanks in advance for any assistance.


Sub Movefile()
OldName = "T:\Accounting\BANKING\Bank of America\Schedule\*.csv"
NewName = "T:\Accounting\BANKING\Formatted Data Files\*.csv"
Name OldName As NewName
End Sub

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Edwin Chavez     Answered On: Mar 02

OK. I have it. I will investigate further.

 
Answer #2    Answered By: Burk Martin     Answered On: Mar 02

It may be the result of all that wine last night but I am puzzled.

I am not aware of a way of using Name as you are in Excel VBA. What library
are you using?

 
Answer #3    Answered By: Hubert Taylor     Answered On: Mar 02

Try this

Sub Movefile()
Dim SourceFolder As String, TargetFolder As String
Dim fs, f, f1, fc, sf, tf
SourceFolder = "T:\Accounting\BANKING\Bank of America\Schedule\"
TargetFolder = "T:\Accounting\BANKING\Formatted Data Files\"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(SourceFolder)
Set fc = f.Files
For Each f1 In fc
If Right(f1.Name, 3) = "csv" Then
sf = SourceFolder & f1.Name
tf = TargetFolder & f1.Name
Name sf As tf
End If
Next
MsgBox "Done"
End Sub

 
Answer #4    Answered By: Lurlene Fischer     Answered On: Mar 02

Drag & Drop operation...Open notepad and copy/paste the code  below
then save it as *.vbs. I coded it so that you could drop file/files
or one folder  into it and the files  will be moved to the destination
folder of your choosing.

Change the "strDestFolder" to your folder and the files will be moved
to that folder.

One convinient way to use this function is to put a short cut of this
file in your "SendTo" folder then when browsing in Windows Explorer,
just right click on the files or folder and send to this file...that
way you don't have to remember where this function is stored in order
to use.

 
Didn't find what you were looking for? Find more on Move & Rename File Or get search suggestion and latest updates.




Tagged: