Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm looking for a way to return only the File Name from the FileDialog object. From what I can see I can only return both the full path and file name. I'm open to suggestion of alternative methods other than FileDialog such as an API but again any API examples I have found only return the full path. Has anybody any suggestions on how i could do this? Thanks Paul |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Most would strip out the filename from the fullpathName
sFileName = Right(sFullPathName,Len(sFullPathBName)-InstrRev(sFullPathName,"\")) demo'd from the immediate window: sFullPathName = "C:\MyMainsubFolder\MySecondarySubFolder\Myfile.xl s" ? sFullPathname C:\MyMainsubFolder\MySecondarySubFolder\Myfile.xls sFileName = Right(sFullPathName,Len(sFullPathName)-InstrRev(sFullPathName,"\")) ? sfileName Myfile.xls -- Regards, Tom Ogilvy "PMC1" wrote: Hi, I'm looking for a way to return only the File Name from the FileDialog object. From what I can see I can only return both the full path and file name. I'm open to suggestion of alternative methods other than FileDialog such as an API but again any API examples I have found only return the full path. Has anybody any suggestions on how i could do this? Thanks Paul |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() If you import GetOpenFileName (comdlg32.dll), the string to return should be the FileTitle, not the FileName... Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pFILETOOPEN As FILETOOPEN) As Long Private Type FILETOOPEN lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type Private Sub GetFileName() Dim FTO As FILETOOPEN FTO.lStructSize = Len(FTO) FTO.hwndOwner = 0 FTO.hInstance = 0 FTO.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0) FTO.lpstrFile = Space$(254) FTO.nMaxFile = 255 FTO.lpstrFileTitle = Space$(254) FTO.nMaxFileTitle = 255 FTO.lpstrInitialDir = "C:\" FTO.lpstrTitle = "Select a File..." FTO.flags = 0 If GetOpenFileName(FTO) Then MsgBox "FileName: " + Trim$(FTO.lpstrFileTitle) Else 'Do nothing End If End Sub "PMC1" schreef in bericht ps.com... Hi, I'm looking for a way to return only the File Name from the FileDialog object. From what I can see I can only return both the full path and file name. I'm open to suggestion of alternative methods other than FileDialog such as an API but again any API examples I have found only return the full path. Has anybody any suggestions on how i could do this? Thanks Paul |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
FileDialog | Excel Programming | |||
using a filedialog box from a dll | Excel Programming | |||
FileDialog to select file | Excel Discussion (Misc queries) | |||
Using FileDialog or GetOpenFileName To Allow File Creation | Excel Programming | |||
FileDialog Help | Excel Programming |