GetOpenFileName()
Posted by: fredometro on
Jan 1st, 2004 |
Filed under: MS-Access
This function is a call to the ‘Open File’ dialog box.
For instance, if you call the function from a button in a form, your call will look like this:
sFilename = gsWinDlgOpen((Me.Hwnd), \”Title of the window\”, \”MyFile.txt\” & Chr$(0) & \”MyFile.txt\” & Chr$(0), \”C:\\\”)
The declaration should be:
Declare Function GetOpenFileNameA Lib \”COMDLG32.DLL\” (tFilename As CMDLG_FILENAME) As Integer
Public Function GetOpenFileName(tFilename As CMDLG_FILENAME) As Integer
GetOpenFileName = GetOpenFileNameA(tFilename)
End Function
Type CMDLG_FILENAME
lStructSize As Long
hWndOwner As Long
hInstance As Long
lpstrsFilter As String
lpstrCustomsFilter As String
nMaxCustsFilter As Long
nsFilterIndex 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
Declare Function GetOpenFileNameA Lib “COMDLG32.DLL” (tFilename As CMDLG_FILENAME) As Integer
Public Function GetOpenFileName(tFilename As CMDLG_FILENAME) As Integer
GetOpenFileName = GetOpenFileNameA(tFilename)
End Function
Const CMDLG_OFN_READONLY = &H1
Const CMDLG_OFN_OVERWRITEPROMPT = &H2
Const CMDLG_OFN_HIDEREADONLY = &H4
Const CMDLG_OFN_NOCHANGEDIR = &H8
Const CMDLG_OFN_SHOWHELP = &H10
Const CMDLG_OFN_ENABLEHOOK = &H20
Const CMDLG_OFN_ENABLETEMPLATE = &H40
Const CMDLG_OFN_ENABLETEMPLATEHANDLE = &H80
Const CMDLG_OFN_NOVALIDATE = &H100
Const CMDLG_OFN_ALLOWMULTISELECT = &H200
Const CMDLG_OFN_EXTENSIONDIFFERENT = &H400
Const CMDLG_OFN_PATHMUSTEXIST = &H800
Const CMDLG_OFN_FILEMUSTEXIST = &H1000
Const CMDLG_OFN_CREATEPROMPT = &H2000
Const CMDLG_OFN_SHAREAWARE = &H4000
Const CMDLG_OFN_NOREADONLYRETURN = &H8000
Const CMDLG_OFN_NOTESTFILECREATE = &H10000
Const CMDLG_OFN_SHAREFALLTHROUGH = 2
Const CMDLG_OFN_SHARENOWARN = 1
Const CMDLG_OFN_SHAREWARN = 0
Function gsWinDlgOpen(hWnd As Long, sTitel As String, sFilter As String, sCurDir As String) As String
Dim tFilename As CMDLG_FILENAME
Dim sFilename As String
Dim sFiletitel As String
Dim sDefExt As String
sTitel = sTitel + Chr$(0)
sFilter = sFilter & “Alle Dateien (*.*)” & Chr$(0) & “*.*” & Chr$(0) & Chr$(0)
sFilename = Chr$(0) & Space$(255) & Chr$(0)
sFiletitel = Chr$(0) & Space$(255) & Chr$(0)
sDefExt = Chr$(0)
sCurDir = gvntNull2Arg(sCurDir, CurDir$) & Chr$(0)
tFilename.lStructSize = Len(tFilename)
tFilename.hWndOwner = hWnd
tFilename.lpstrsFilter = sFilter
tFilename.nsFilterIndex = 1
tFilename.lpstrFile = sFilename
tFilename.nMaxFile = Len(sFilename)
tFilename.lpstrFileTitle = sFiletitel
tFilename.nMaxFileTitle = Len(sFiletitel)
tFilename.lpstrTitle = sTitel
tFilename.Flags = CMDLG_OFN_FILEMUSTEXIST Or CMDLG_OFN_HIDEREADONLY
tFilename.lpstrInitialDir = sCurDir
If GetOpenFileName(tFilename) <> 0 Then
gsWinDlgOpen = gsTrim(tFilename.lpstrFile)
Else
gsWinDlgOpen = “”
End If
End Function
Function gsTrim(s As String) As String
gsTrim = Trim$(Left$(s, InStr(1, s & Chr$(0), Chr$(0), 0) - 1))
End Function
Function gvntNull2Arg(vntExp As Variant, vntPara As Variant) As Variant
If gbNull(vntExp) Then
gvntNull2Arg = vntPara
Else
gvntNull2Arg = vntExp
End If
End Function
Function gbNull(vnt As Variant) As Integer
On Error GoTo gbNullError
Select Case VarType(vnt)
Case V_NULL, V_EMPT
gbNull = True
Case V_STRING
gbNull = (Len(gsTrim(CStr(vnt))) = 0)
Case V_DATE
gbNull = False
Case Else
gbNull = (vnt = 0)
End Select
gbNullExit:
Exit Function
gbNullError:
gbNull = True
Resume gbNullExit
End Function


December 11th, 2009 at 11:52 pm
Erotic Movie Station
December 11th, 2009 at 11:53 pm
LadyBoy 69
December 11th, 2009 at 11:54 pm
Male Celebrities
December 11th, 2009 at 11:55 pm
La Zona Modelos
December 11th, 2009 at 11:56 pm
Tinsley Towers
December 11th, 2009 at 11:57 pm
Young Porn
December 11th, 2009 at 11:58 pm
MILFs Wild Holiday
December 12th, 2009 at 12:00 am
Southern Brooke
December 12th, 2009 at 12:01 am
Nextdoor Kellie
December 12th, 2009 at 12:02 am
Internal Pass
December 12th, 2009 at 12:03 am
Naughty Cum Sluts
December 12th, 2009 at 12:04 am
I Just Fucked My Best Friends Mom
December 12th, 2009 at 12:05 am
Jizz GFs
December 12th, 2009 at 12:06 am
Ariel Jordan
December 12th, 2009 at 12:07 am
123 Big Tit Britney
December 12th, 2009 at 12:08 am
Lacey Pink
December 13th, 2009 at 8:40 pm
I highly enjoyed reading this article, keep on creating such interesting articles.
December 29th, 2009 at 11:00 pm
Test topic for you!
Add A Comment
You must be logged in to post a comment.