I had the same problem and have since sworn off dialogue controls. Use the Windows API instead. Drop api code into a module as is and then you just call it thus:
strFileName = apiOpenFile
API Code:
[tt]
Private Declare Function apiGetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
'END API DECLARATIONS ----------------------------------------------
'TYPE DECLARATIONS -----------------------------------------------------
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
' END TYPE DECLARATIONS --------------------------------------------------
'Constants for OpenFileDialog
Private Const cdlOFNAllowMultiselect = &H200
Private Const cdlOFNCreatePrompt = &H2000
Private Const cdlOFNExplorer = &H80000
Private Const cdlOFNExtensionDifferent = &H400
Private Const cdlOFNFileMustExist = &H1000
Private Const cdlOFNHelpButton = &H10
Private Const cdlOFNHideReadOnly = &H4
Private Const cdlOFNLongNames = &H200000
Private Const cdlOFNNoChangeDir = &H8
Private Const CdlOFNNoDereferenceLinks = &H100000
Private Const cdlOFNNoLongNames = &H40000
Private Const CdlOFNNoReadOnlyReturn = &H8000
Private Const cdlOFNNoValidate = &H100
Private Const cdlOFNOverwritePrompt = &H2
Private Const cdlOFNPathMustExist = &H800
Private Const cdlOFNReadOnly = &H1
Private Const CdlOFNShareAware = &H4000
Public Function apiOpenFile(strFilterType As String, _
Optional strDialogTitle As String = "Name of File to Open"

As String
On Error GoTo Error_apiOpenFile
Dim lngReturn As Long
Dim strFilter As String
Dim intLocNull As Integer
Dim strTemp As String
Dim ofnFileInfo As OPENFILENAME
Dim strInitialDir As String
Select Case strFilterType
Case "Word"
strFilter = "Word Docs (*.doc)" & Chr(0) & "*.doc" & Chr(0)
Case "Excel"
strFilter = "Excel Files (*.xls)" & Chr(0) & "*.xls" & Chr(0)
Case "Access"
strFilter = "Access Files (*.mdb)" & Chr(0) & "*.mdb" & Chr(0)
Case Else
strFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0)
End Select
strInitialDir = CurrentProject.Path
'strFileName = String(256, 0)
With ofnFileInfo
.lStructSize = Len(ofnFileInfo)
.lpstrFile = String(256, 0)
.lpstrFileTitle = String(256, 0)
.lpstrInitialDir = strInitialDir
.hwndOwner = Application.hWndAccessApp
.lpstrFilter = strFilter
.nFilterIndex = 1
.nMaxFile = 256 'Len(strFileName)
.nMaxFileTitle = ofnFileInfo.nMaxFile
.lpstrTitle = strDialogTitle
.flags = cdlOFNFileMustExist Or cdlOFNHideReadOnly Or _
cdlOFNNoChangeDir
.hInstance = 0
.lpstrCustomFilter = String(255, 0)
.nMaxCustFilter = 255
.lpfnHook = 0
End With
lngReturn = apiGetOpenFileName(ofnFileInfo)
If lngReturn = 0 Then
strTemp = ""
Else
'-- Trim off any null terminator
strTemp = Trim(ofnFileInfo.lpstrFile)
intLocNull = InStr(strTemp, Chr(0))
If intLocNull Then
strTemp = Left(strTemp, intLocNull - 1)
End If
End If
apiOpenFile = strTemp
Error_apiOpenFile:
Exit Function
End Function
[/tt]
Turn your headache into my project!
Jeffrey R. Roberts
Insight Data Consulting
Access and SQL Server Development