[AccessD] Missing GetFilePath function

Arthur Fuller artful at rogers.com
Sat Jan 14 10:23:08 CST 2006


In case anyone else needs it, here it is:
<code>
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
strFilter As String
strCustomFilter As String
lMaxCustFilter As Long
lFilterIndex As Long
strFile As String
lMaxFile As Long
strFileTitle As String
lMaxFileTitle As Long
strInitialDir As String
strTitle As String
lFlags As Long
iFileOffset As Integer
iFileExtension As Integer
strDefExt As String
lCustData As Long
lpfnHook As Long
strTemplateName As String
End Type

Public Function GetFilePath( _
    Filter As String, _
    Title As String, _
    Optional DefaultDir As String) _
    As String
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
Dim i As Integer
OpenFile.lStructSize = Len(OpenFile)
'OpenFile.hwndOwner = Application.h
OpenFile.hInstance = 0
OpenFile.strFilter = Filter
OpenFile.lFilterIndex = 1
OpenFile.strFile = String(257, 0)
OpenFile.lMaxFile = Len(OpenFile.strFile) - 1
OpenFile.strFileTitle = OpenFile.strFile
OpenFile.lMaxFileTitle = OpenFile.lMaxFile

If IsMissing(DefaultDir) Or (DefaultDir = "") Then
    OpenFile.strInitialDir = CurDir
Else
    OpenFile.strInitialDir = DefaultDir
End If

OpenFile.strTitle = Title
OpenFile.lFlags = 0
lReturn = GetOpenFileName(OpenFile)

If lReturn = 0 Then
    GetFilePath = ""
Else
    i = InStr(OpenFile.strFile, vbNullChar)
    If i > 0 Then
        GetFilePath = Left(OpenFile.strFile, i - 1)
    Else
        GetFilePath = OpenFile.strFile
    End If
End If

End Function

</code>
Arthur

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: January 14, 2006 7:16 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Compact by code

Where is the code for GetFilePath()? I have something vaguely similar but I
figured rather than experiment with making mine and yours compatible, I
would simply ask for it.
Arthur
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Monday, November 21, 2005 12:54 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Compact by code

Sorry, GetFilePath() returns the path of a given file name string.
Bobby

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list