Mine was similar to Rick's, but uses the same API...
Option Explicit
Private Declare Function GetOpenFileName _
Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" ( _
pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
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
Sub Open_Comdlg32()
'Originally from Ivan F. Moala:
http://www.xcelfiles.com/comdlg.html
Dim OpenFile As OPENFILENAME, lReturn As Long, strFilter As String,
FileToOpen As String
OpenFile.lStructSize = Len(OpenFile)
strFilter = "My Files (*.url)" & Chr(0) & "*.url" & Chr(0)
With OpenFile
.lpstrFilter = strFilter
.nFilterIndex = 1
.lpstrFile = String(257, 0)
.nMaxFile = Len(.lpstrFile) - 1
.lpstrFileTitle = .lpstrFile
.nMaxFileTitle = .nMaxFile
.lpstrInitialDir = "C:\Users\Zack\Desktop\"
.lpstrTitle = "My FileFilter Open"
.flags = 0
End With
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "User cancelled"
Else
FileToOpen = Application.WorksheetFunction.Clean(OpenFile.lpstrFile)
MsgBox FileToOpen, vbInformation, "FILE PATH & NAME"
End If
End Sub
HTH
--
Zack Barresse
Gary''s Student said:
Thank you Zack.
Using your suggestion does restrict the files displayed in the Dialog box.
If I click on a file with the extension .url, I do not get the
path-filename,
I still get the url value itself.
I don't need and don't want the target of the url:
http://www.......
I need the path and file name of the file I selected in the Dialog box:
C:\Documents and Settings\Owner\Favorites\news.url