[RESOLVED] "Method 'ShowOpen' of object 'ICommonDialog' failed"
Whenever I try to open a common dialog box using the ShowOpen method, I get the following error:
Quote:
Run-time error '32765':
Method 'ShowOpen' of object 'ICommonDialog' failed
After doing some searching (with Google and the MSDN search feature) I found out that the cmdlg32.hlp help file, MSDN and a few other websites all provide this very helpful piece of information:
Quote:
cdlInitialization &H&H7FFD
& The function failed during initialization
This is what I found out myself:
-This error does not occur while running under Microsoft Windows 98.
-Reinstalling Visual Basic does not solve the problem.
-Compatibility mode does not help.
-Using another version of Comdlg32.ocx does not help.
I'm pretty much at a loss as to the cause and how to solve it, if any one can help out, it will be appreciated. The file Project1.zip contains some code that reproduces the error.
btw:
I'm using the Cmdlg32.ocx activeX control version 6.0.84.18.
EDIT:
New information added.
Re: "Method 'ShowOpen' of object 'ICommonDialog' failed"
The only thing in your attachment is a .bas module.
Are you not using any forms with this?
Re: "Method 'ShowOpen' of object 'ICommonDialog' failed"
No, I'm not using forms. Therefore I need to access the common dialog box in a different way than you would otherwise do. But, I think it's highly unlikely that this is the cause of my problem, the code works fine under Windows 98. Although I will admit that the common dialog control does work when using it inside a form.
Re: "Method 'ShowOpen' of object 'ICommonDialog' failed"
Here is some information produced by Microsoft Dependency Walker: http://www.euronet.nl/users/swinkels/procsort.dwi
Hopefully some one can make sense of all that information, and tell me something about what is causing the error described in my message above.
Re: "Method 'ShowOpen' of object 'ICommonDialog' failed"
I solved the problem by opening the common dialog box using the API.
Here is some example code:
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
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.