MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Change Name Directory


Posted by Ronald on September 26, 2001 5:25 AM

Anybody who can tell me how to change the name of a directory running a macro?


Posted by Ivan F Moala on September 26, 2001 10:54 PM

Lookup help on Name
Here is an example;

'Renames Files
Public Sub RenamePath(OldPath As String, NewPath As String)
On Error Resume Next
'Renames a disk file, directory, or folder.
'In Microsoft Windows:
'OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE"
'Name OldName As NewName ' Move and rename file.

Name OldPath As NewPath
If Err.Number <> 0 Then GoTo ErrRename

Exit Sub
ErrRename:
MsgBox Err.Number & " : " & Err.Description

End Sub

Ivan