LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Renaming File Statement -How does it work??

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.
 
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
Problem with renaming work sheet name D Moonn Excel Discussion (Misc queries) 2 April 19th 09 12:21 PM
VB file renaming. El Bee Excel Worksheet Functions 2 January 23rd 08 01:49 AM
renaming all work-sheets at once Narendra Boga[_2_] Excel Discussion (Misc queries) 4 June 6th 07 03:24 AM
vb code for renaming a work sheet with a cell reference John Britto Excel Discussion (Misc queries) 3 September 17th 06 07:12 PM
Renaming a file Paul C[_2_] Excel Programming 1 January 23rd 04 04:13 PM


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