Grabbing Only the FileName from a Common Dialog
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
Re: Grabbing Only the FileName from a Common Dialog
Use
.FileTitle Instead of .FileName
Cheers,
Sharath
Re: Grabbing Only the FileName from a Common Dialog
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