View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
William Benson William Benson is offline
external usenet poster
 
Posts: 121
Default Renaming File Statement -How does it work??

I removed Application. and it worked

thanks

"William Benson" wrote in message
...
application.shell("Command.com /c ren C:\Test.xls C:\Test.txt")

gives me an error message: "Object doesn't support this property or
method"

"Jim Thomlinson" wrote in message
...
This is one of those places where I sometimes like to use a DOS Shell.
Something like this..."

application.shell("Command.com /c ren C:\Test.xls C:\Test.txt")

The advantage of using a shell is that you can do mutiple files at
once...

application.shell("Command.com /c ren C:\*.xls C:\*.txt")

Depends on what you are trying to do as to whether a DOS shell is the
best
solution or not...
--
HTH...

Jim Thomlinson


"KAHAUS" wrote:

Could someone please explain how this Excel 2003 VBA routine works to
rename
a file.
Assume oldfilename.txt exist in the C:\temp directory, when the name
statement executes, it is renamed to "newfilename.txt"

Sub RenameTheFiles()
ChDir "C:\Temp\"
Name "oldfilename.txt" As "newfilename.txt"
End Sub

Originally I was using a multi step routine using the FileSystemObject
and
setting a fileObject.Name = new name, thus performing the rename. The
simplicity of this code is confusing what I thought I knew about the
object
models. Specifically, Name in the above routine is a method? How is it
associated, what is the object or how does it know to rename the file in
the
temp directory??? Can anyone give me the complete syntax of the name
statement? I assume there to be several defaults omitted. What role
does the
"AS" play? Is this some kind of shorthand for a SET statement?

Puzzled!

Fred Krause.