Private Type OfficeGetFileName_Info hwndOwner As Long szAppName As String * 255 szDlgTitle As String * 255 szOpenTitle As String * 255 szFile As String * 4096 szInitialDir As String * 255 szFilter As String * 255 nFilterIndex As Long lView As Long flags As Long End Type Private Declare Function OfficeGetFileName _ Lib "msaccess.exe" Alias "#56" _ (gfni As OfficeGetFileName_Info, _ ByVal fOpen As Integer) As Long '「ファイルを開く」の例 Dim tOgfn As OfficeGetFileName_Info With tOgfn .hwndOwner = Me.Hwnd .szAppName = Me.Caption & vbNullChar .szOpenTitle = vbNullChar .szDlgTitle = "ファイルの選択" & vbNullChar .szFile = vbNullChar .szInitialDir = "C:\My Documents" & vbNullChar .szFilter = "Microsoft Access (*.mdb,*.mde,*.mda)|" & _ "*.mdb;*.mde;*.mda||" & vbNullChar .flags = &H2 If OfficeGetFileName(tOgfn, True) = 0 Then MsgBox Left$(.szFile, InStr(.szFile, vbNullChar) - 1) Else MsgBox "キャンセル" End If End With '「名前を付けて保存」の例 '「ファイルを開く」の例の以下の部分の、True を False にすればいいです。 If OfficeGetFileName(tOgfn, True) = 0 Then ↓ If OfficeGetFileName(tOgfn, False) = 0 Then '「フォルダの選択」の例 Dim tOgfn As OfficeGetFileName_Info With tOgfn .hwndOwner = Me.Hwnd .szAppName = Me.Caption & vbNullChar .szOpenTitle = vbNullChar .szDlgTitle = "フォルダの選択" & vbNullChar .szFile = vbNullChar .szInitialDir = "C:\My Documents" & vbNullChar .szFilter = vbNullChar .flags = &H20 If OfficeGetFileName(tOgfn, True) = 0 Then MsgBox Left$(.szFile, InStr(.szFile, vbNullChar) - 1) Else MsgBox "キャンセル" End If End With