Stuart McLachlan
stuart at lexacorp.com.pg
Tue Jul 5 16:01:03 CDT 2011
Here' ya go, I'm sure I've posted this a few times in the past. Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long 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 Function GetFileName(Directory As String) As String Dim OpenFile As OPENFILENAME Dim lReturn As Long Dim sFilter As String OpenFile.lStructSize = Len(OpenFile) OpenFile.hwndOwner = 0 OpenFile.hInstance = 0 sFilter = "" & Chr(0) OpenFile.lpstrFilter = sFilter OpenFile.nFilterIndex = 0 OpenFile.lpstrFile = String(257, 0) OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1 OpenFile.lpstrFileTitle = OpenFile.lpstrFile OpenFile.nMaxFileTitle = OpenFile.nMaxFile OpenFile.lpstrInitialDir = Directory OpenFile.lpstrTitle = "Select File" OpenFile.flags = 0 lReturn = GetOpenFileName(OpenFile) GetFileName = Left$(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile, Chr$(0)) - 1) End Function On 5 Jul 2011 at 16:28, Arthur Fuller wrote: > I may have asked this before; if so, please forgive the redundancy. > I've got an old app that I'm sprucing up with A2K7 to run on Windows > 7. Some code I lifted from the ADH musketeers no longer works. It > seems that the CommonDlg thingie has vanished. > > I need essentially that functionality, but that works in A2K7 and > A2K10: It opens the Windows Open/Save dialog with a bunch of > arguments: >