I found this:
Public Const OFN_ALLOWMULTISELECT = &H200
Public Const OFN_CREATEPROMPT = &H2000
Public Const OFN_ENABLEHOOK = &H20
Public Const OFN_ENABLETEMPLATE = &H40
Public Const OFN_ENABLETEMPLATEHANDLE = &H80
Public Const OFN_EXPLORER = &H80000
Public Const OFN_EXTENSIONDIFFERENT = &H400
Public Const OFN_FILEMUSTEXIST = &H1000
Public Const OFN_HIDEREADONLY = &H4
Public Const OFN_LONGNAMES = &H200000
Public Const OFN_NOCHANGEDIR = &H8
Public Const OFN_NODEREFERENCELINKS = &H100000
Public Const OFN_NOLONGNAMES = &H40000
Public Const OFN_NONETWORKBUTTON = &H20000
Public Const OFN_NOREADONLYRETURN = &H8000
Public Const OFN_NOTESTFILECREATE = &H10000
Public Const OFN_NOVALIDATE = &H100
Public Const OFN_OVERWRITEPROMPT = &H2
Public Const OFN_PATHMUSTEXIST = &H800
Public Const OFN_READONLY = &H1
Public Const OFN_SHAREAWARE = &H4000
Public Const OFN_SHAREFALLTHROUGH = 2
Public Const OFN_SHAREWARN = 0
Public Const OFN_SHARENOWARN = 1
Public Const OFN_SHOWHELP = &H10
Public Const OFS_MAXPATHNAME = 128
'OFS_FILE_OPEN_FLAGS and OFS_FILE_SAVE_FLAGS below
'are mine to save long statements; they're not
'a standard Win32 type.
Public Const OFS_FILE_OPEN_FLAGS = OFN_EXPLORER Or OFN_LONGNAMES Or
OFN_CREATEPROMPT Or OFN_NODEREFERENCELINKS
Public Const OFS_FILE_SAVE_FLAGS = OFN_EXPLORER Or OFN_LONGNAMES Or
OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY
Public Type OPENFILENAME
nStructSize As Long
hwndOwner As Long
hInstance As Long
sFilter As String
sCustomFilter As String
nCustFilterSize As Long
nFilterIndex As Long
sFile As String
nFileSize As Long
sFileTitle As String
nTitleSize As Long
sInitDir As String
sDlgTitle As String
flags As Long
nFileOffset As Integer
nFileExt As Integer
sDefFileExt As String
nCustDataSize As Long
fnHook As Long
sTemplateName As String
End Type
Public OFN As OPENFILENAME
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public Declare Function GetSaveFileName Lib "comdlg32.dll" Alias
"GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
Public Declare Function GetShortPathName Lib "kernel32" Alias
"GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As
String, ByVal cchBuffer As Long) As Long
Public Function File_Dialog(ByVal File_Op As String, ByVal Multi_Select As
Boolean, ByVal FilterString As String, ByVal FilterExt As String, ByVal
TitleString As String) As String
Dim r As Long
Dim sp As Long
Dim LongName As String
Dim shortName As String
Dim ShortSize As Long
'to keep lines short(er), I've abbreviated a
'Null$ to n and n2, and the filter$ to f.
Dim n As String
Dim n2 As String
Dim f As String
n = Chr$(0)
n2 = n & n
'------------------------------------------------
'INITIALIZATION
'------------------------------------------------
'fill in the size of the OFN structure
OFN.nStructSize = Len(OFN)
'assign the owner of the dialog; this can
'be null if no owner.
'OFN.hwndOwner = Form1.hwnd
'------------------------------------------------
'FILTERS
'------------------------------------------------
'Using OFN.sFilter, fills
'the combo with the specified filters, and works as
'the VB common dialog does. These must be in the
'"Friendly Name"-null$-Extension format,
'terminating with 2 null strings.
f = FilterString & n & FilterExt & n
OFN.sFilter = f
'nFilterIndex specifies an index into
'the buffer pointed to by sFilter. The system uses the
'index value to obtain a pair of strings to use as the
'initial filter description and filter pattern for the
'dialog box. The first pair of strings has an index value
'of 1. When the user closes the dialog box, the system
'copies the index of the selected filter strings
'into this location.
OFN.nFilterIndex = 2 ' "AutoCAD Drawings"
'------------------------------------------------
'FILENAME
'------------------------------------------------
'sFile points to a buffer that contains a filename used
'to initialize the File Name edit control. The first
'character of this buffer must be NULL if initialization
'is not necessary. When the GetOpenFileName or GetSaveFileName
'function returns, this buffer contains the drive designator,
'path, filename, and extension of the selected file.
'pass a default filename and initialize for
'return value
OFN.sFile = FilterExt & Space$(1024) & n
OFN.nFileSize = Len(OFN.sFile)
'default extension applied to a selected file if
'it has no extension.
OFN.sDefFileExt = FilterExt
'sFileTitle points to a buffer that receives the
'title of the selected file. The application should
'use this string to display the file title. If this
'member is NULL, the function does not copy the file
'title.
OFN.sFileTitle = Space$(512)
OFN.nTitleSize = Len(OFN.sFileTitle)
'sInitDir is the string that specifies the initial
'file directory. If this member is NULL, the system
'uses the current directory as the initial directory.
'OFN.sInitDir = "d:\vb4\projects\misc\common dialogs"
'------------------------------------------------
'MISC
'------------------------------------------------
'sDlgTitle is the title to display in the dialog. If null
'the default title for the dialog is used.
OFN.sDlgTitle = TitleString
'flags are the actions and options for the dialog.
Select Case File_Op
Case "Open"
If Multi_Select = True Then
OFN.flags = OFS_FILE_OPEN_FLAGS + OFN_ALLOWMULTISELECT
Else
OFN.flags = OFS_FILE_OPEN_FLAGS
End If
r = GetOpenFileName(OFN)
Case "Save"
If Multi_Select = True Then
OFN.flags = OFS_FILE_SAVE_FLAGS + OFN_ALLOWMULTISELECT
Else
OFN.flags = OFS_FILE_SAVE_FLAGS
End If
r = GetSaveFileName(OFN)
End Select
'Finally, show the File Open Dialog
'------------------------------------------------
'RESULTS
'------------------------------------------------
If r Then
'Path & File Returned (OFN.sFile):
Dim FileString As String
Dim I As Integer
Do Until Right(FileString, 2) = Chr$(0) & " " Or Right(FileString, 2) =
Chr$(0) & Chr$(0)
I = I + 1
FileString = Left(OFN.sFile, I)
Loop
File_Dialog = Left(FileString, I - 2)
'File Path (from OFN.nFileOffset):
'Text2 = Left$(OFN.sFile, OFN.nFileOffset)
'File Name (from OFN.nFileOffset):
'Text3 = Mid$(OFN.sFile, OFN.nFileOffset + 1, Len(OFN.sFile) -
OFN.nFileOffset - 1)
'Extension (from OFN.nFileExt):
'Text4 = Mid$(OFN.sFile, OFN.nFileExt + 1, Len(OFN.sFile) -
OFN.nFileExt)
'File Name (OFN.sFileTitle):
'Text5 = OFN.sFileTitle
'Short 8.3 File Name (using (OFN.sFileTitle):
'LongName = OFN.sFileTitle
'shortName = Space$(128)
'ShortSize = Len(shortName)
'sp = GetShortPathName(LongName, shortName, ShortSize)
'Text6 = Left$(shortName, sp)
'Short 8.3 File Name (using OFN.sFile):
'LongName = OFN.sFile
'shortName = Space$(128)
'ShortSize = Len(shortName)
'sp = GetShortPathName(LongName, shortName, ShortSize)
'Text7 = Left$(shortName, sp)
'User Requested this file be opened as Read Only:
'chkReadOnly.Value = Abs((OFN.flags And OFN_READONLY) = OFN_READONLY)
End If
End Function
then call using this code
Dim FileName As String
FileName = File_Dialog("Open", True, "AutoCAD Drawing (*.dwg)", "*.dwg",
"Open")