GetOpenFileName can't select a .URL file?

D

Dick

any advice?

The code that I used:
dim sFile as string
if VBGetOpenFiles( sFile, True, True, "URLs(*.url)|*.url", , , , Me.hwnd)
then
msgbox "OK"
end if


'In a module

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
Private Const MAX_FILE = 260
Private Const OFN_ALLOWMULTISELECT = &H200
Private Const OFN_EXPLORER = &H80000
Private Const OFN_FILEMUSTEXIST = &H1000

Public Function VBGetOpenFiles(FileName As String, _
Optional FileMustExist As Boolean = True, _
Optional MultiSelect As Boolean = False, _
Optional Filter As String = "All (*.*)| *.*", _
Optional InitDir As String, _
Optional DlgTitle As String, _
Optional DefaultExt As String, _
Optional hwnd As Long = 0) As Boolean

Dim OFName As OPENFILENAME
With OFName
.lStructSize = Len(OFName)
.hWndOwner = hwnd
.hInstance = App.hInstance
.lpstrDefExt = DefaultExt
.lpstrInitialDir = InitDir
.lpstrTitle = DlgTitle
If MultiSelect Then
.lpstrFile = FileName & String$(2048 - Len(FileName), 0)
.nMaxFile = 2048
.lpstrFileTitle = String$(2048, 0)
.nMaxFileTitle = 2048
.Flags = OFN_ALLOWMULTISELECT Or OFN_EXPLORER
Else
.lpstrFile = FileName & String$(MAX_FILE - Len(FileName), 0)
.nMaxFile = MAX_FILE
.lpstrFileTitle = String$(MAX_FILE, 0)
.nMaxFileTitle = MAX_FILE
.Flags = 0
End If
.Flags = .Flags Or (-FileMustExist * OFN_FILEMUSTEXIST)
.lpstrFilter = Replace(Filter, "|", vbNullChar) & vbNullChar &
vbNullChar
End With
VBGetOpenFiles = GetOpenFileName(OFName)
FileName = Trim$(OFName.lpstrFile)
End Function
 

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