Hello,

Rather than using the Common Dialog, I created it to a Function through API's.

The dialog works fine, without a prob, but it seems like once it is initialised (opened), then when the form unloads VB always crashes.

Is this something to do with it not releasing some handle properly ?
Heres the code. Note: This is the UniCode aware version GetOpenFileNameW
Code:
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameW" (pOpenfilename As OPENFILENAME) As Long

Private Const OFN_FILEMUSTEXIST = &H1000
Private Const OFN_HIDEREADONLY As Long = &H4

Private Type OPENFILENAME
  lStructSize       As Long
  hWndOwner         As Long
  hInstance         As Long
  lpstrFilter       As Long
  lpstrCustomFilter As Long
  nMaxCustFilter    As Long
  nFilterIndex      As Long
  lpstrFile         As Long
  nMaxFile          As Long
  lpstrFileTitle    As Long
  nMaxFileTitle     As Long
  lpstrInitialDir   As Long
  lpstrTitle        As Long
  flags             As Long
  nFileOffset       As Integer
  nFileExtension    As Integer
  lpstrDefExt       As Long
  lCustData         As Long
  lpfnHook          As Long
  lpTemplateName    As Long
End Type

Public Function cDlgShowOpen(ByVal InitialDir As String, ByVal DialogTitle As String, ByVal Filter As String, ByVal FrmhWnd As Long) As String
On Error GoTo ErrFound

Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim strFile As String
Dim FileFilter As String

        strFile = String(512, 0)
        OpenFile.lStructSize = Len(OpenFile)
        OpenFile.hWndOwner = FrmhWnd
        OpenFile.hInstance = App.hInstance
        
          FileFilter = Replace(Filter, "|", vbNullChar)
          If AscW(Right$(FileFilter, 1)) <> 0& Then FileFilter = FileFilter & vbNullChar
        OpenFile.lpstrFilter = StrPtr(FileFilter)
        OpenFile.nFilterIndex = 1
        
        OpenFile.lpstrFile = StrPtr(strFile) 'String(257, 0)
        OpenFile.nMaxFile = Len(strFile)
        
        OpenFile.lpstrFileTitle = StrPtr(OpenFile.lpstrFile)
        OpenFile.nMaxFileTitle = StrPtr(OpenFile.nMaxFile)
        OpenFile.lpstrInitialDir = StrPtr(InitialDir)
        OpenFile.lpstrTitle = StrPtr(DialogTitle)
        OpenFile.flags = OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
        lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
'Cancel Button Pressed
Else
   cDlgShowOpen = Left$(strFile, InStr(strFile, vbNullChar) - 1)
   'cDlgShowOpen = Replace(OpenFile.lpstrFile, vbNullChar, "")
End If

Exit Function
ErrFound:
cDlgShowOpen = ""
End Function