|
-
Jul 8th, 2004, 09:43 PM
#1
Thread Starter
Hyperactive Member
renaming file
RENAMING FOLDER:
Hi I use this code below to rename a file:
Dim aName As String
aName = InputBox("Rename file", "Type new file name")
Dim NewName As String, OldName As String
NewName = aName 'new
OldName = Dir1.List(Dir1.ListIndex) & "\" & File1.FileName 'old
FirstOccurrence = InStrRev(OldName, "\")
NewName = Left(OldName, FirstOccurrence) & NewName 'overwrite
Name OldName As NewName 'change
Dir1.Refresh
But my problem, is there extension name. Like for example, I am going to rename a file with the extension name of ".doc", what code should I write, if I ever type the" .doc " or not to the new filename, automatically it will save the file wih the extension name of ".doc"
Help me please??
-
Jul 9th, 2004, 02:59 AM
#2
Hyperactive Member
You can do something like this maybe
....
VB Code:
Dim sName as string
dim NewName as string
sName = InputBox("Rename File", "Boo")
If Not InStr(1, sName, ".doc") Then '- If the file doesnt contain .doc
NewName = sName & ".doc" '- Then add it
'// Save NewName...
End If
Born to help others
(If I've been helpful then please rate my post. Thanks)
call me EJ or be slapped! 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|