#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default FileName

Is there a way to rename a file, any file, on my C: drive with this property
in Excel VBA?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default FileName

To rename a closed file
(it must be closed)

oldfile = "C:\My Files\Myfile.txt"
newfile = "C:\My Files\MyNewFile.txt"
name oldfile as newfile

--
Regards,
Tom Ogilvy

"Spencer Hutton" wrote in message
...
Is there a way to rename a file, any file, on my C: drive with this

property
in Excel VBA?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default FileName

VBA help:

Name Statement


Renames a disk file, directory, or folder.

Syntax

Name oldpathname As newpathname

The Name statement syntax has these parts:

Part Description
oldpathname Required. String expression that specifies the existing file
name and location — may include directory or folder, and drive.
newpathname Required. String expression that specifies the new file name
and location — may include directory or folder, and drive. The file name
specified by newpathname can't already exist.



Remarks

The Name statement renames a file and moves it to a different directory
or folder, if necessary. Name can move a file across drives, but it can
only rename an existing directory or folder when both newpathname and
oldpathname are located on the same drive. Name cannot create a new
file, directory, or folder.

Using Name on an open file produces an error. You must close an open
file before renaming it. Name arguments cannot include
multiple-character (*) and single-character (?) wildcards.


Spencer Hutton wrote:
Is there a way to rename a file, any file, on my C: drive with this property
in Excel VBA?


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
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
+ in filename mkrefting Excel Discussion (Misc queries) 0 October 24th 06 07:44 PM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
Saving filename same as import filename Matt Excel Programming 4 February 24th 04 03:01 PM
how to specify the filename gptg13 Excel Programming 0 December 18th 03 11:31 PM


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