PDA

View Full Version : Solved: Crazy Request



gsouza
06-20-2005, 04:49 AM
Good morning people, if anybody can help,

Is it possible with VB in excel to search a folder to find all files with .xls extentions and remove the extenion to nothing. (book1.xls to book1.)

Steiner
06-20-2005, 05:16 AM
This one should to it, it looks for .xls and simply takes the filename up to the .:
Option Explicit
Sub ChangeExt()
Dim strPath$, strFile$, iPos%

' Change this, don't forget the trailing \
strPath = "e:\test\xls\"

strFile = Dir(strPath & "*.xls")

Do While strFile <> ""
Debug.Print strPath & strFile
iPos = InStr(strFile, ".xls")
Name strPath & strFile As strPath & Left(strFile, iPos)
strFile = Dir
Loop
End Sub


Daniel

gsouza
06-20-2005, 05:23 AM
Works perfectly, thank you so much

Steiner
06-20-2005, 05:25 AM
No problem, and be sure to mark this thread as solved if it is. To do that, have a look at the top of your first post, there you should see a dropdown menu "ThreadTools" where you can mark this thread solved.

Daniel

sheeeng
06-20-2005, 08:37 PM
Thanks, Steiner (http://www.vbaexpress.com/forum/member.php?u=91).
I have looking for these code for long.
:friends: