how to get folder path

J

Jon

Greeting,

I have a code to get the full path of file, but what I need is only the
folder name. is there any way to get folder name only??

Thank you.
 
J

Jon

By the way,

I am using the following code:
im fileName As String

Dim arrFileName() As String

Dim result As Integer

With Application.FileDialog(msoFileDialogFilePicker)


.Title = "Select Employee Picture"

.Filters.Add "All Files", "*.*"

.Filters.Add "JPEGs", "*.jpg"

.Filters.Add "Bitmaps", "*.bmp"

.FilterIndex = 2

.AllowMultiSelect = False

.InitialFileName = CurrentProject.Path

result = .Show

If (result <> 0) Then

arrFileName() = Split(.SelectedItems.Item(1), "\", -1)

fileName = "\" + arrFileName(UBound(arrFileName) - 1) + "\" +
arrFileName(UBound(arrFileName))

Me![photo].Visible = True

Me![photo].SetFocus

Me![photo].Text = fileName
End If

End With
 
D

Douglas J. Steele

Realistically, he did provide "full code".

Let's try it again, though. Let's assume your full path to the file is
stored in variable strFullPath and you want the folder name put into
strFolderName.

strFolderName = Mid$(strFullPath,InStrRev(strFullPath,"\")+1)

Regarding your other post in this thread (where you showed your code), do
yourself a huge favour, and stop using the FileDialog control. Using the API
is far more reliable. You can get a complete sample at
http://www.mvps.org/access/api/api0001.htm at "The Access Web"
 
T

Tom Wickerath

T

Tom Wickerath

Hi Jon,

Excuse me--I was incorrect when I stated that my sample uses the API method.
It is currently using the File Dialog method. I guess I had not gotten around
to changing this over yet to the API-based common file dialog method. That is
on the list of things-to-do, as time permits, and I thought I had already
done this. Apparently not.

I do use the API method in all new projects. The frmEmployees form in my
photo database sample was imported from the copy of Northwind that ships with
Access 2003. This already included the FileDialog file picking code.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top