Click to See Complete Forum and Search --> : Grabbing Only the FileName from a Common Dialog


HerickPaiva
April 27th, 2001, 09:27 AM
Hi,

The Following code loads a file from a path chosen using Common dialog 6:

With cdopen '---->>>>This is the name of the common dialog control object
'
.DialogTitle = "Select Movie File/Image to be Imported..."
.FileName = ""
.Filter = "Tutorial Files (*.wmv*,*.jpg*)|*.wmv*;*.txt*"
.ShowOpen


If Len(.FileName) <> 0 Then

mstream.LoadFromFile .FileName
rs.Fields("MM_entity").Value = mstream.Read
'Update
rs("MMType_id") = 2
rs("MM_Caption") = "Test"
rs.Fields("MM_filename").Value = cdopen.FileName <<<<<<----Help Here
rs.Update
End If
If .FileName = "" Then
GoTo Command3_Error
End If

End With


After Selecting the file, it gets saved to a DB. As you see, I insert the .FileName value into a Field in the DB. The thing is, I only want to grab the file name. When saving, this code is inserting the whole path as well. Can you guys help me on how to grab only the FileName????

Thanks,

Herick

Sharathms
April 27th, 2001, 09:34 AM
Use
.FileTitle Instead of .FileName
Cheers,
Sharath

briana02
April 27th, 2001, 09:44 AM
Herick, I'm writing an app that does the exact same thing. I used the .FileTitle property to get ONLY the filename from the open dialog. Give it a try
fileName = .cdOpen.FileTitle

Brian