PDA

View Full Version : Remove the file extention from the file list



Pixelpusher
10-21-2009, 12:56 AM
Hi all,
does anyone know how to remove the file extention from the file list returned with the code below. I have been trying to adapt this "WBname = Replace(wb. Name, ".xls", "") but with no joy. Thanks



Private Sub UserForm_Initialize()
Dim sFile As String

sFile = Dir$("E:\WADE\records_excel\*.*")

Do Until sFile = ""
If Left$(sFile, 1) <> "." Then
list1.AddItem sFile
End If
sFile = Dir$
Loop

End Sub

GTO
10-21-2009, 01:09 AM
Greetings Pixelpusher,

Welcome to the forum :-)

Please note that starting one thread here five minutes after you started a thread here:

http://www.mrexcel.com/forum/showthread.php?t=423975

...is not polite to those who try and help by answering. Please read http://www.excelguru.ca/node/7

Mark

Pixelpusher
10-21-2009, 01:17 AM
I apologise if this is not the done thing I was just trying to find a quick solution.

GTO
10-21-2009, 01:35 AM
Hi again,:hi:

Not a problem at all. I hope I did not sound terse. As you just joined, please let me be the the first to say Welcome! and a friendly Howdy from Arizona. vbaexpress is a great place, and I'll bet you'll be happy you joined:thumb .

Have a great day,

Mark

p45cal
10-21-2009, 04:43 AM
List1.AddItem Left(sFile, InStrRev(sFile, ".") - 1)

mdmackillop
10-21-2009, 01:30 PM
You can also use Split, although it will fail with two . in the name (but then I never name files that way!)



List1.AddItem Split(sFile,".")(0)