I solved the problem by opening the common dialog box using the API.
Here is some example code:
The above code works without forms. Initially I got the same error as described in my earlier posts when using the API. I don't know exactly how, but I got it to work now.Code:Option Explicit 'The open file dialog information. Private Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustomFilter 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 'The common dialog flag constants. Private Const cdlOFNAllowMultiselect As Long = &H200 Private Const cdlOFNExplorer As Long = &H80000 Private Const cdlOFNHideReadOnly As Long = &H4 Private Const cdlOFNFileMustExist As Long = &H1000 Private Const cdlOFNLongNames As Long = &H200000 Private Const cdlOFNPathMustExist As Long = &H800 'Some Microsoft Windows API's used by Procedure Sorter. Private Declare Function CommDlgExtendedError Lib "Comdlg32.dll" () As Long Private Declare Function GetOpenFileNameA Lib "Comdlg32.dll" (lpofn As OPENFILENAME) As Long Sub Main() Dim Dialog As OPENFILENAME Dialog.lStructSize = Len(Dialog) GetOpenFileNameA Dialog End Sub




Reply With Quote