Вы можете использовать WinAPI для этого. Импорт
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Вы также должны импортировать структуру OPENFILENAME.
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
Затем вы заполняете структуру и вызываете GetOpenFileName.
Dim of As OPENFILENAME
of.lStructSize = Len(of)
of.hwndOwner = Access.hWndAccessApp
of.hInstance = vbNull
of.lpstrFilter = m_strFilter ' *.doc for example
of.nFilterIndex = 1
of.lpstrFile = String(257, 0)
of.nMaxFile = Len(of.lpstrFile) - 1
of.lpstrFileTitle = of.lpstrFile
of.nMaxFileTitle = of.nMaxFile
of.lpstrInitialDir = m_strDirectory ' Folder to start
of.lpstrTitle = m_strTitle ' Title of dialog window
of.Flags = 0
If GetOpenFileName(of) <> 0 Then
filename = VBString(of.lpstrFile)
end if
Где VBString - вспомогательная функция для преобразования строки с нулевым символом в конце.
Private Function VBString(str As String) As String
Dim pos As Integer
pos = InStr(1, str, Chr(0), vbTextCompare)
VBString = Left(str, pos - 1)
End Function