On Error GoTo ErrorHandler 'エラー処理ルーチンを実行します。

Dim Returnvalue As Variant
Dim strMsg As String
Returnvalue = Application.Version
strMsg = "Access2002、2003でないため、この機能を利用できません。"
'Accessのバージョンを調べます。
'Access2000は10.0、Access2000は9.0,Access97は8.0,Access95は7.0を返します。
If Returnvalue >= "12.0" Then
Dim inttype As Integer
Dim varSelectedFile As Variant
'ファイルを選択する場合は、msofiledialogfilepicker
'フォルダーを選択する場合は、msofiledialogfolderpicker
inttype = msoFileDialogFolderPicker
'ファイル参照用の設定値をセットします。
With Application.FileDialog(inttype)
'ダイアログタイトル名
.Title = strTitle
'最初に開くホルダー
.InitialFileName = strPath
If .Show = -1 Then 'ファイルが選択されれば -1 を返します。
For Each varSelectedFile In .SelectedItems
FolderSelect = varSelectedFile
Next
End If
End With
Else
MsgBox strMsg, vbOKOnly, ""
End If
End Function